-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (52 loc) · 1.94 KB
/
Dockerfile
File metadata and controls
66 lines (52 loc) · 1.94 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# syntax=docker/dockerfile:1
# --- Build stage ---
FROM golang:1.25.10 AS builder
WORKDIR /build
# Node.js is needed to build the SvelteKit frontend
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
apt-get install -y nodejs
COPY . .
# Build the frontend
RUN --mount=type=cache,target=/root/.npm \
cd web/frontend && npm ci && npm run build
# Copy built frontend into the Go embed directory
RUN rm -rf internal/web/frontend && \
mkdir -p internal/web/frontend && \
cp -r web/frontend/build/* internal/web/frontend/
# Build the server binary with the embedded frontend
ARG version=unknown
RUN CGO_ENABLED=0 go build \
-ldflags="-w -s \
-X github.com/IBM/simrun/internal/version.Version=${version} \
-X github.com/IBM/simrun/internal/version.Commit=$(git rev-parse --short HEAD 2>/dev/null || echo unknown) \
-X github.com/IBM/simrun/internal/version.BuildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-o /simrun-server cmd/simrun/main.go
# --- Runtime stage ---
FROM alpine:3.21
RUN apk add --no-cache \
ca-certificates \
git \
openssh-client \
curl \
aws-cli \
python3 \
py3-pip
# Google Cloud SDK (https://cloud.google.com/sdk/docs/install-sdk#linux)
ARG TARGETARCH
RUN case "${TARGETARCH}" in \
arm64) GCLOUD_ARCH=arm ;; \
*) GCLOUD_ARCH=x86_64 ;; \
esac && \
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-linux-${GCLOUD_ARCH}.tar.gz && \
tar -xf google-cloud-cli-linux-${GCLOUD_ARCH}.tar.gz && \
./google-cloud-sdk/install.sh --quiet --path-update=false && \
rm google-cloud-cli-linux-${GCLOUD_ARCH}.tar.gz
ENV PATH="/google-cloud-sdk/bin:${PATH}"
# Azure CLI
RUN pip3 install --no-cache-dir --break-system-packages azure-cli
# Run as a non-root user
RUN addgroup -S nonroot && adduser -S -G nonroot nonroot
COPY --from=builder /simrun-server /simrun-server
USER nonroot
WORKDIR /
ENTRYPOINT ["/simrun-server"]