From 579a2ac26b59ffedf7a20aedb12bd2584fa3e7e8 Mon Sep 17 00:00:00 2001 From: hgw Date: Sun, 10 Dec 2023 05:21:33 +0000 Subject: [PATCH] Improve Dockerfile --- Dockerfile | 8 ++++++-- docker-compose.yml | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index dcf08d8..8cda2d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,12 @@ -FROM golang:1.21-alpine -WORKDIR /app +FROM golang:1.21-alpine as builder +WORKDIR /build COPY go.mod go.sum ./ RUN go mod download COPY *.go ./ RUN go build -o hardfiles main.go + +FROM golang:1.21-alpine as app +WORKDIR /app +COPY --from=builder /build/hardfiles . RUN mkdir files CMD ["./hardfiles"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index f314f99..071fb16 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,6 +2,7 @@ services: hardfiles: container_name: hardfiles image: git.supernets.org/supernets/hardfiles:latest + build: . volumes: - "$PWD/files:/app/files" - "$PWD/www:/app/www"