Added Docker and short instructions
Better documentation and process to come
This commit is contained in:
parent
da0f1ddf2d
commit
540fd269df
2
.env
2
.env
|
|
@ -1 +1 @@
|
|||
DATABASE_URL=postgres://username:password@localhost/request_mirror_db
|
||||
DATABASE_URL=postgres://postgres:password@localhost/request_mirror_db
|
||||
|
|
@ -0,0 +1 @@
|
|||
DATABASE_URL=postgres://postgres:password@postgres/request_mirror_db
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
FROM rustlang/rust:nightly as builder
|
||||
WORKDIR ./app
|
||||
COPY . .
|
||||
RUN cargo install --path .
|
||||
|
||||
FROM debian:bookworm-slim as runner
|
||||
RUN apt update && apt install -y libpq-dev libc6
|
||||
COPY --from=builder /usr/local/cargo/bin/request-mirror /usr/local/bin/request-mirror
|
||||
COPY ./templates /templates
|
||||
COPY .env.docker .env
|
||||
ENV ROCKET_ADDRESS=0.0.0.0
|
||||
ENV ROCKET_ENV=production
|
||||
EXPOSE 8000
|
||||
CMD ["request-mirror"]
|
||||
13
README.md
13
README.md
|
|
@ -4,3 +4,16 @@ This application provides a web ui for sending get/post requests and provides a
|
|||
## TODO:
|
||||
- Update Readme
|
||||
- Document
|
||||
- Setup Docker
|
||||
|
||||
## Docker
|
||||
|
||||
This is the current setup for getting the webapp to work with docker. This may not work on your machine, this is beta.
|
||||
|
||||
```bash
|
||||
cd request-mirror
|
||||
|
||||
sh deploy.sh
|
||||
```
|
||||
|
||||
This will setup the container. A better setup will come in the future.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
# Set Rust to nightly
|
||||
rustup default nightly
|
||||
|
||||
# Install Diesel
|
||||
cargo install diesel_cli --no-default-features --features postgres
|
||||
|
||||
# New Network
|
||||
docker network create postgres-net
|
||||
|
||||
# Setup postgres container
|
||||
docker pull postgres
|
||||
docker run -d --rm -p 5432:5432 --name postgres --net postgres-net -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=password postgres
|
||||
|
||||
# Setup db with diesel
|
||||
diesel database run
|
||||
diesel migration run
|
||||
|
||||
# Build and start request-mirror
|
||||
docker build . -t raspberrypi99/request-mirror
|
||||
docker run -d --rm -p 8000:8000 --name request-mirror --net postgres-net raspberrypi99/request-mirror
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
version: 3.8
|
||||
|
||||
services:
|
||||
request-mirror:
|
||||
image: request-mirror
|
||||
ports:
|
||||
- 80:80
|
||||
environment:
|
||||
- DB_HOST=postgres
|
||||
depends_on:
|
||||
- postgres
|
||||
networks:
|
||||
- app-network
|
||||
|
||||
postgres:
|
||||
image: postgres
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=password
|
||||
- POSTGRES_DB=request_mirror_db
|
||||
volumes:
|
||||
- db-data:/var/lib/postgresql/data
|
||||
networks:
|
||||
- app-network
|
||||
|
||||
networks:
|
||||
app-network:
|
||||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.16.0.0/24
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
Loading…
Reference in New Issue