This commit is contained in:
parent
6498ac56d9
commit
92f6a89f25
20
Dockerfile
20
Dockerfile
|
@ -1,14 +1,6 @@
|
||||||
# Load the golang image
|
# Load nodego image
|
||||||
FROM golang:1.21.0 as go-builder
|
FROM maronato/nodego:1.0 as builder
|
||||||
# Then the node image
|
|
||||||
FROM node:20.5.0 as builder
|
|
||||||
|
|
||||||
# Copy golang into the node image
|
|
||||||
COPY --from=go-builder /usr/local/go /usr/local/go
|
|
||||||
|
|
||||||
# Now our base image is ready.
|
|
||||||
|
|
||||||
# Continue as normal
|
|
||||||
WORKDIR /go/src/app
|
WORKDIR /go/src/app
|
||||||
|
|
||||||
# Set our build environment
|
# Set our build environment
|
||||||
|
@ -22,8 +14,6 @@ ENV ENV_DOCKER=true
|
||||||
# Copy dockerignore files
|
# Copy dockerignore files
|
||||||
COPY .dockerignore ./
|
COPY .dockerignore ./
|
||||||
|
|
||||||
COPY Makefile ./
|
|
||||||
|
|
||||||
# Install go deps using the cache
|
# Install go deps using the cache
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN --mount=type=cache,target=/tmp/.go-build-cache \
|
RUN --mount=type=cache,target=/tmp/.go-build-cache \
|
||||||
|
@ -33,11 +23,11 @@ RUN --mount=type=cache,target=/tmp/.go-build-cache \
|
||||||
COPY frontend/package.json frontend/package-lock.json frontend/
|
COPY frontend/package.json frontend/package-lock.json frontend/
|
||||||
RUN npm config set cache /tmp/.npm-cache --global
|
RUN npm config set cache /tmp/.npm-cache --global
|
||||||
RUN --mount=type=cache,target=/tmp/.npm-cache \
|
RUN --mount=type=cache,target=/tmp/.npm-cache \
|
||||||
make install
|
npm ci --prefix frontend
|
||||||
|
|
||||||
# Build the frontend
|
# Build the frontend
|
||||||
COPY frontend frontend
|
COPY frontend frontend
|
||||||
RUN make frontend
|
RUN VITE_API_URL=/api npm run --prefix frontend build
|
||||||
|
|
||||||
# Build backend
|
# Build backend
|
||||||
COPY goshort.go ./
|
COPY goshort.go ./
|
||||||
|
@ -46,7 +36,7 @@ COPY internal internal
|
||||||
|
|
||||||
# Build the backend
|
# Build the backend
|
||||||
RUN --mount=type=cache,target=/tmp/.go-build-cache \
|
RUN --mount=type=cache,target=/tmp/.go-build-cache \
|
||||||
make backend
|
CGO_ENABLED=0 go build -o goshort goshort.go
|
||||||
|
|
||||||
# Now create a new image with just the binary
|
# Now create a new image with just the binary
|
||||||
FROM gcr.io/distroless/static-debian11:nonroot
|
FROM gcr.io/distroless/static-debian11:nonroot
|
||||||
|
|
Loading…
Reference in New Issue
Block a user