|
| 1 | +FROM ghcr.io/libops/go1.25:main@sha256:f43c9b34f888d2ac53e87c8e061554f826b8eb580863d7b21fd787b6f0378f8f AS builder |
| 2 | + |
| 3 | +SHELL ["/bin/ash", "-o", "pipefail", "-ex", "-c"] |
| 4 | + |
| 5 | +WORKDIR /app |
| 6 | + |
| 7 | +COPY go.mod go.sum ./ |
| 8 | +COPY proto/ ./proto/ |
| 9 | +RUN --mount=type=cache,target=/go/pkg/mod \ |
| 10 | + go mod download |
| 11 | + |
| 12 | +COPY *.go ./ |
| 13 | +COPY internal/ ./internal/ |
| 14 | +COPY db/ ./db/ |
| 15 | + |
| 16 | +RUN --mount=type=cache,target=/root/.cache/go-build \ |
| 17 | + CGO_ENABLED=0 go build -ldflags="-s -w" -o /app/binary . |
| 18 | + |
| 19 | +FROM node:22-alpine AS frontend |
| 20 | + |
| 21 | +WORKDIR /app |
| 22 | + |
| 23 | +# Copy package files and install dependencies |
| 24 | +COPY web/package.json web/package-lock.json ./ |
| 25 | +RUN npm ci |
| 26 | + |
| 27 | +# Copy source files and build configuration |
| 28 | +COPY web/src/ ./src/ |
| 29 | +COPY web/tsconfig.json web/vite.config.ts web/vite-plugin-proto-resolver.ts ./ |
| 30 | + |
| 31 | +# Build the frontend bundle |
| 32 | +RUN npm run build |
| 33 | + |
| 34 | +FROM ubuntu:24.04 AS tailwind |
| 35 | + |
| 36 | +SHELL ["/bin/bash", "-o", "pipefail", "-c"] |
| 37 | + |
| 38 | +WORKDIR /app |
| 39 | + |
| 40 | +RUN apt-get update && apt-get install curl --yes && \ |
| 41 | + curl -sL \ |
| 42 | + https://github.com/tailwindlabs/tailwindcss/releases/download/v4.1.18/tailwindcss-linux-x64 \ |
| 43 | + -o /app/tailwindcss && \ |
| 44 | + chmod +x /app/tailwindcss |
| 45 | + |
| 46 | +COPY web/ ./web/ |
| 47 | +# Copy the bundled JavaScript from frontend stage |
| 48 | +COPY --from=frontend /app/static/js/main.bundle.js ./web/static/js/main.bundle.js |
| 49 | + |
| 50 | +RUN /app/tailwindcss \ |
| 51 | + -i ./web/static/css/input.css \ |
| 52 | + -o ./web/static/css/output.css \ |
| 53 | + --content './web/templates/**/*.html,./web/src/**/*.ts' \ |
| 54 | + --minify |
| 55 | + |
| 56 | + |
| 57 | +FROM ghcr.io/libops/go1.25:main@sha256:f43c9b34f888d2ac53e87c8e061554f826b8eb580863d7b21fd787b6f0378f8f |
| 58 | + |
| 59 | +WORKDIR /app |
| 60 | +COPY --from=builder /app/binary /app/binary |
| 61 | +COPY web/ ./web/ |
| 62 | +COPY --from=tailwind /app/web/static/css/output.css ./web/static/css/output.css |
| 63 | +COPY --from=frontend /app/static/js/main.bundle.js ./web/static/js/main.bundle.js |
| 64 | + |
| 65 | +COPY openapi/ ./openapi/ |
| 66 | + |
| 67 | +EXPOSE 8080 |
| 68 | + |
| 69 | +HEALTHCHECK CMD /bin/bash -c 'curl -sf http://localhost:8080/health' |
0 commit comments