60 lines
1.2 KiB
Docker
60 lines
1.2 KiB
Docker
# Load nodego image
|
|
FROM maronato/nodego:1.0 as builder
|
|
|
|
RUN apk add --no-cache make
|
|
|
|
ARG VERSION=undefined
|
|
|
|
WORKDIR /go/src/app
|
|
|
|
# Set our build environment
|
|
ENV GOPATH=/go
|
|
ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
|
|
# This variable communicates to the service that it's running inside
|
|
# a docker container.
|
|
ENV ENV_DOCKER=true
|
|
|
|
# Copy dockerignore files
|
|
COPY .dockerignore ./
|
|
|
|
# Install go deps
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download -x
|
|
|
|
# Install node deps
|
|
COPY frontend/package.json frontend/package-lock.json frontend/
|
|
RUN npm ci --prefix frontend
|
|
|
|
COPY Makefile ./
|
|
|
|
# Build the frontend
|
|
COPY frontend frontend
|
|
RUN VITE_API_URL=/api VITE_OIDC_URL=/odc npm run --prefix frontend build
|
|
|
|
# Build backend
|
|
COPY goshort.go ./
|
|
COPY cmd cmd
|
|
COPY internal internal
|
|
COPY docs docs
|
|
|
|
# Build the backend
|
|
RUN make backend VERSION=$VERSION
|
|
|
|
# Now create a new image with just the binary
|
|
FROM gcr.io/distroless/static-debian11:nonroot
|
|
|
|
WORKDIR /app
|
|
|
|
# Set our runtime environment
|
|
ENV ENV_DOCKER=true
|
|
ENV GOSHORT_PROD=true
|
|
|
|
COPY --from=builder /go/src/app/goshort /usr/local/bin/goshort
|
|
|
|
HEALTHCHECK CMD [ "goshort", "healthcheck" ]
|
|
|
|
EXPOSE 8080
|
|
|
|
ENTRYPOINT [ "goshort" ]
|
|
CMD [ "serve" ]
|