Skip to content

Commit 04448d3

Browse files
committed
add docker files
1 parent 4a619e4 commit 04448d3

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/target

Dockerfile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM rust:1.69-buster as builder
2+
3+
WORKDIR /app
4+
5+
ARG DB_URL
6+
7+
ENV DB_URL=$DB_URL
8+
9+
COPY . .
10+
11+
RUN cargo build --release
12+
13+
14+
FROM debian:buster-slim
15+
16+
WORKDIR /usr/local/bin
17+
18+
COPY --from=builder /app/target/release/rust-crud-api .
19+
20+
CMD ["./rust-crud-api"]

docker-compose.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: '3.9'
2+
3+
services:
4+
5+
app:
6+
image: rustapp:latest
7+
build:
8+
context: .
9+
dockerfile: Dockerfile
10+
args:
11+
DB_URL: postgres://postgres:postgres@db:5432/postgres
12+
ports:
13+
- '8080:8080'
14+
depends_on:
15+
- db
16+
17+
db:
18+
image: postgres:12
19+
environment:
20+
POSTGRES_USER: postgres
21+
POSTGRES_PASSWORD: postgres
22+
POSTGRES_DB: postgres
23+
ports:
24+
- '5432:5432'
25+
volumes:
26+
- pgdata:/var/lib/postgresql/data
27+
28+
volumes:
29+
pgdata: {}

0 commit comments

Comments
 (0)