-
Notifications
You must be signed in to change notification settings - Fork 177
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (37 loc) · 1.74 KB
/
Copy pathDockerfile
File metadata and controls
41 lines (37 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
ARG JUICE_SHOP_VERSION=latest
FROM --platform=$BUILDPLATFORM docker.io/golang:1.26 AS builder
WORKDIR /src
COPY go.mod go.sum ./
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
COPY cmd/multi-juicer ./cmd/multi-juicer
COPY internal ./internal
ARG TARGETOS TARGETARCH
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 \
go build -o /out/multi-juicer ./cmd/multi-juicer
RUN chmod +x /out/multi-juicer
FROM --platform=$BUILDPLATFORM docker.io/library/node:26-alpine AS ui
WORKDIR /home/app
COPY package.json package-lock.json .npmrc ./
RUN --mount=type=cache,target=/root/.npm \
npm ci --ignore-scripts
COPY tsconfig.json biome.json ./
COPY ui/ ./ui/
RUN --mount=type=cache,target=/root/.npm \
--mount=type=cache,target=/home/app/node_modules/.vite \
npm run build
# get the challenges from the juice-shop image
FROM docker.io/bkimminich/juice-shop:${JUICE_SHOP_VERSION} AS juice-shop
# convert them to json so that we don't need to pull in a yaml lib
FROM docker.io/mikefarah/yq:4 AS challenges-json
COPY --from=juice-shop /juice-shop/data/static/challenges.yml /workdir/challenges.yaml
RUN yq eval --output-format json '.' /workdir/challenges.yaml > /workdir/challenges.json
FROM gcr.io/distroless/static:nonroot
COPY --from=challenges-json --chown=root:root --chmod=755 /workdir/challenges.json /challenges.json
COPY --from=ui --chown=root:root --chmod=755 /home/app/ui/build/ /public/
COPY --from=builder --chown=root:root --chmod=755 /out/multi-juicer /multi-juicer
CMD ["/multi-juicer"]