sorarebuddy/Dockerfile
2024-06-06 09:52:54 +04:00

34 lines
940 B
Docker

ARG GO_VERSION=1.22.1
FROM oven/bun as node-builder
WORKDIR /app
COPY front/package.json front/bun.lockb ./
RUN bun install --frozen-lockfile
COPY front/ ./
RUN bun run build
FROM golang:${GO_VERSION}-alpine as go-builder
RUN apk add --update ca-certificates git tzdata
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY ./ ./
RUN rm -rf ./cmd/server/dist
COPY --from=node-builder /app/dist ./cmd/server/dist
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /server ./cmd/server/.
FROM busybox:glibc
RUN mkdir /app
RUN addgroup -S server && adduser -S -s /bin/false -G server server
WORKDIR /app
COPY --from=go-builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=go-builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=go-builder /server /app/server
RUN chown -R server:server /app
USER server
EXPOSE 8080
ENTRYPOINT ["/app/server"]