Skip to content

Commit d97d193

Browse files
Merge branch 'docker' into main
2 parents 7333afc + 49a34ac commit d97d193

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

backend/Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM rustlang/rust:nightly-alpine3.15 AS builder
2+
3+
RUN apk update && apk add --no-cache build-base openssl-dev gcompat libc6-compat bash
4+
WORKDIR /build/zer0bin
5+
6+
COPY Cargo.toml .
7+
RUN echo "fn main() {}" >> dummy.rs
8+
RUN sed -i 's#src/main.rs#dummy.rs#' Cargo.toml
9+
ENV RUSTFLAGS=-Ctarget-feature=-crt-static
10+
RUN if [[ $(uname -m) =~ ^arm ]]; then CARGO_INCREMENTAL=1 cargo build --release --target aarch64-unknown-linux-musl; else CARGO_INCREMENTAL=1 cargo build --release; fi
11+
RUN rm dummy.rs && sed -i 's#dummy.rs#src/main.rs#' Cargo.toml
12+
COPY . .
13+
RUN CARGO_INCREMENTAL=1 cargo build --release
14+
15+
FROM alpine:3.15
16+
17+
WORKDIR /backend
18+
RUN apk update && apk add --no-cache build-base openssl
19+
COPY --from=builder /build/zer0bin/target/release/zer0bin-bin .
20+
21+
CMD ["/backend/zer0bin-bin"]

docker-compose.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
version: "3"
2+
3+
services:
4+
backend:
5+
build:
6+
context: "./backend"
7+
restart: always
8+
tty: true
9+
ports:
10+
- "8000:8000"
11+
networks:
12+
- app-network
13+
depends_on:
14+
- postgres
15+
16+
frontend:
17+
build:
18+
context: "./frontend"
19+
restart: always
20+
tty: true
21+
volumes:
22+
- frontend-volume:/var/www/frontend
23+
24+
postgres:
25+
image: postgres:alpine
26+
restart: always
27+
tty: true
28+
environment:
29+
POSTGRES_USER: postgres
30+
POSTGRES_DB: zer0bin
31+
POSTGRES_PASSWORD: postgres
32+
networks:
33+
- app-network
34+
volumes:
35+
- postgres-volume:/var/lib/postgresql/data
36+
37+
nginx:
38+
image: nginx:alpine
39+
restart: always
40+
tty: true
41+
ports:
42+
- "80:80"
43+
- "443:443"
44+
depends_on:
45+
- backend
46+
volumes:
47+
- ./example.nginx:/etc/nginx/conf.d/default.conf
48+
- frontend-volume:/var/www/frontend
49+
networks:
50+
- app-network
51+
52+
networks:
53+
app-network:
54+
driver: bridge
55+
56+
volumes:
57+
postgres-volume:
58+
frontend-volume:

frontend/Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM node:16-alpine3.14
2+
3+
WORKDIR /var/www/frontend
4+
5+
COPY package.json ./
6+
RUN yarn
7+
COPY . .
8+
9+
RUN yarn build

0 commit comments

Comments
 (0)