From 6775243bb588ff00a8ee5c9b896da5ee97320604 Mon Sep 17 00:00:00 2001 From: Laszlo Fogas Date: Fri, 4 Oct 2024 20:04:11 +0200 Subject: [PATCH] Experiment --- docker/Dockerfile.multistage | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 docker/Dockerfile.multistage diff --git a/docker/Dockerfile.multistage b/docker/Dockerfile.multistage new file mode 100644 index 0000000..4236917 --- /dev/null +++ b/docker/Dockerfile.multistage @@ -0,0 +1,38 @@ +FROM golang:1.23-alpine AS gobuild + +WORKDIR /go/src/github.com/gimlet-io/capacitor + +COPY . . + +RUN mkdir -p bin +RUN GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o bin/linux/amd64/capacitor github.com/gimlet-io/capacitor/cmd/capacitor + +FROM node:22-alpine AS npmbuild + +WORKDIR /src + +COPY web . + +RUN npm ci +RUN npm run build + +FROM --platform=$TARGETPLATFORM alpine:3 + +RUN addgroup -S capacitor && adduser -S capacitor -G capacitor + +ADD docker/known_hosts /etc/ssh/ssh_known_hosts + +RUN mkdir /var/lib/capacitor +RUN chown capacitor:capacitor /var/lib/capacitor +WORKDIR /capacitor + +ARG TARGETPLATFORM +ARG BUILDPLATFORM + +COPY --from=gobuild --chown=capacitor:capacitor /go/src/github.com/gimlet-io/capacitor/bin/linux/amd64/capacitor capacitor +COPY --from=npmbuild --chown=capacitor:capacitor /src/build ./web/build/ + +USER capacitor + +EXPOSE 9000 +CMD ["/capacitor/capacitor"]