Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Stage 1: Build frontend
FROM node:20-alpine AS frontend-builder
FROM --platform=$BUILDPLATFORM node:20-alpine AS frontend-builder

WORKDIR /app/web

Expand All @@ -16,7 +16,11 @@ COPY web/ ./
RUN npm run build

# Stage 2: Build backend
FROM golang:1.25.4-alpine AS backend-builder
FROM --platform=$BUILDPLATFORM golang:1.25.4-alpine AS backend-builder

# Build arguments for cross-compilation
ARG TARGETOS
ARG TARGETARCH

WORKDIR /app

Expand All @@ -36,8 +40,8 @@ COPY . .
# Copy frontend build from previous stage
COPY --from=frontend-builder /app/web/dist ./web/dist

# Build the Go application
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o tracker .
# Build the Go application for target platform
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-w -s" -o tracker .

# Stage 3: Final runtime image
FROM alpine:latest
Expand Down
Loading