Skip to content

Commit

Permalink
feat: new dockerfile and docker-compose.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
vasthecat committed Mar 28, 2024
1 parent c4e6e2b commit 261e540
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DATABASE_URL=postgres://user:pass@postgres:5432/db
LISTEN_ADDRESS=0.0.0.0:8000
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
target/
Cargo.lock
*.swp
.*
!.gitignore
!.dockerignore
!.env.example
12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
FROM debian:bullseye as final
FROM rust:buster

WORKDIR /opt/app
COPY ./target/release/web_service .
ENV CARGO_HOME=/rust
WORKDIR /app
COPY . .
RUN apt-get install libssl-dev
RUN --mount=type=cache,target=/app/target \
cargo build --release && cp ./target/release/web_service /bin
ENTRYPOINT [ "/bin/web_service" ]

# CMD ["./web_service"]
31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: "3.8"

services:
mysqldb:
image: mysql:8
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: db
volumes:
- .:/data
postgres:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: example
poem-sqlx-service:
container_name: poem-sqlx-service
build: .
deploy:
restart_policy:
condition: on-failure
ports:
- "8000:8000"
environment:
- "DATABASE_URL=${DATABASE_URL?please set}"
- "LISTEN_ADDRESS=${LISTEN_ADDRESS:-0.0.0.0:8000}"
- "RUST_BACKTRACE=${BACKTRACE:-1}"
- "RUST_LOG=${LOG_LEVEL:-debug}"
tty: true

0 comments on commit 261e540

Please sign in to comment.