docker: Use multi-stage docker builds

Signed-off-by: Gunwant Jain <mail@wantguns.dev>
This commit is contained in:
Gunwant Jain
2022-01-16 22:04:05 +05:30
parent 449f0c38a9
commit 0359a8ef52
2 changed files with 9 additions and 7 deletions

View File

@@ -1,17 +1,20 @@
FROM rust:1 as builder FROM rust:1 as builder
WORKDIR /app WORKDIR /app
COPY . . COPY . .
RUN RUSTFLAGS='-C target-feature=+crt-static' cargo install --target x86_64-unknown-linux-gnu --path .
RUN cargo install --path .
RUN cargo clean RUN cargo clean
FROM debian:buster-slim as runner
WORKDIR /app
RUN mkdir -p upload RUN mkdir -p upload
COPY ./client upload/client COPY ./client upload/client
COPY ./templates templates COPY ./templates templates
COPY ./static static COPY ./static static
COPY ./themes themes
COPY --from=builder /usr/local/cargo/bin/bin .
ENV ROCKET_ADDRESS=0.0.0.0 ENV ROCKET_ADDRESS=0.0.0.0
ENV ROCKET_PORT=6162 ENV ROCKET_PORT=6162
EXPOSE 6162 EXPOSE 6162
CMD ["bin"] CMD ["./bin"]

View File

@@ -1,13 +1,12 @@
version: '3.3' version: '3.3'
services: services:
pastebin: pastebin:
build: . image: wantguns/bin
# image: wantguns/bin
container_name: pastebin container_name: pastebin
ports: ports:
- 127.0.0.1:6162:6162 - 127.0.0.1:6162:6162
environment: environment:
- ROCKET_PORT=6162 # Port the app uses - ROCKET_PORT=6162
- HOST_URL=localhost:6162 # or bin.example.com - ROCKET_LIMITS={form="16 MiB"}
volumes: volumes:
- ./upload:/app/upload # upload folder will have your pastes - ./upload:/app/upload # upload folder will have your pastes