From 0359a8ef5273d767646b699352338fefddf9e2e3 Mon Sep 17 00:00:00 2001 From: Gunwant Jain Date: Sun, 16 Jan 2022 22:04:05 +0530 Subject: [PATCH] docker: Use multi-stage docker builds Signed-off-by: Gunwant Jain --- Dockerfile | 9 ++++++--- docker-compose.yml | 7 +++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index eba6e56..242e42a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,20 @@ FROM rust:1 as builder WORKDIR /app COPY . . - -RUN cargo install --path . +RUN RUSTFLAGS='-C target-feature=+crt-static' cargo install --target x86_64-unknown-linux-gnu --path . RUN cargo clean +FROM debian:buster-slim as runner +WORKDIR /app RUN mkdir -p upload COPY ./client upload/client COPY ./templates templates COPY ./static static +COPY ./themes themes +COPY --from=builder /usr/local/cargo/bin/bin . ENV ROCKET_ADDRESS=0.0.0.0 ENV ROCKET_PORT=6162 EXPOSE 6162 -CMD ["bin"] +CMD ["./bin"] diff --git a/docker-compose.yml b/docker-compose.yml index 8934fd6..07ffdc2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,13 +1,12 @@ version: '3.3' services: pastebin: - build: . - # image: wantguns/bin + image: wantguns/bin container_name: pastebin ports: - 127.0.0.1:6162:6162 environment: - - ROCKET_PORT=6162 # Port the app uses - - HOST_URL=localhost:6162 # or bin.example.com + - ROCKET_PORT=6162 + - ROCKET_LIMITS={form="16 MiB"} volumes: - ./upload:/app/upload # upload folder will have your pastes