From d299ea6e7601b067c412323caff9d39afdbb9fc1 Mon Sep 17 00:00:00 2001 From: blek Date: Sat, 11 Nov 2023 17:58:50 +1000 Subject: [PATCH] deploy resourced to production dockerfile Note: I did not test the compose file on my machine before submitting the commit. May or may not work. --- docker-compose.prod.yml | 9 +++++++++ resource/Dockerfile.prod | 22 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 resource/Dockerfile.prod diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 4ac8eb2..fcbd1fe 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -19,6 +19,15 @@ services: volumes: - './janitor:/config:ro' - './volatile/files:/opt/user_uploads' + resourced: + build: + context: resource + dockerfile: Dockerfile.prod + networks: + bfile: + pid: host # prefork + volumes: + - './resource:/opt/cont' caddy: image: caddy:alpine volumes: diff --git a/resource/Dockerfile.prod b/resource/Dockerfile.prod new file mode 100644 index 0000000..0451ed0 --- /dev/null +++ b/resource/Dockerfile.prod @@ -0,0 +1,22 @@ +FROM golang:alpine3.17 as builder + +WORKDIR /opt/build +COPY . . + +RUN apk add --no-cache git musl-dev upx binutils + +RUN go build . && \ + strip resourced && \ + upx resourced + +FROM alpine:3.17 + +WORKDIR /opt/code +COPY --from=builder /opt/build/resourced /usr/bin/resourced + +# Note +# ----- +# Since this is running with prefork, don't +# forget to set --pid=host when running this app + +CMD [ "sh", "-c", "/usr/bin/resourced" ]