From 3534cbf3cd6a618958779ddb340f7754d8e44e96 Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Thu, 4 Apr 2024 02:37:23 -0400 Subject: [PATCH] finalized Dockerfile --- .dockerignore | 6 ++++++ Dockerfile | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8a8ac50 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +node_modules +.git +.gitignore +*.md +build +tmp diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..22aa58f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM node:20-alpine AS styles +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" +RUN corepack enable +COPY . /app +WORKDIR /app +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile +RUN pnpm run tw:prod + +FROM golang:1.22.0 as builder +WORKDIR /app +COPY go.mod go.sum ./ +RUN go mod download + +COPY *.go ./ + +RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o ./build/potoforio . + +FROM alpine as runner +WORKDIR /go +COPY --from=builder /app/build/potoforio ./ +COPY --from=styles /app/static ./static +COPY --from=styles /app/views ./views + +EXPOSE 5173 + +ENV GO_ENV="production" + +ENTRYPOINT ["./potoforio"]