Penyesuaian flow repo

This commit is contained in:
M1 AIR
2026-01-09 10:52:56 +07:00
parent bf9eb91ea2
commit 79112e0da8
3 changed files with 162 additions and 224 deletions
+28 -15
View File
@@ -1,25 +1,38 @@
FROM node:20-alpine
RUN apk add --no-cache git bash build-base curl
# =========================
# Builder stage
# =========================
FROM golang:1.23-alpine AS builder
RUN apk add --no-cache git ca-certificates tzdata
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# Buat config agar Next tahu output: export
RUN echo "const config = { output: 'export', images: { unoptimized: true } }; export default config;" > next.config.mjs
# Build API binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -trimpath -ldflags="-s -w" -o lti-api ./cmd/api
# Build project (Next.js 15 otomatis static export)
RUN NEXT_DISABLE_TURBOPACK=1 npx next build
# Build SEED binary (pastikan cmd/seed ada)
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -trimpath -ldflags="-s -w" -o lti-seed ./cmd/seed
# Copy static assets dan hasil build agar bisa diakses
RUN mkdir -p .next/server/app/_next && \
cp -r .next/static .next/server/app/_next/static && \
cp -r public/* .next/server/app/
# =========================
# Runtime stage
# =========================
FROM alpine:3.20
EXPOSE 3000
RUN apk add --no-cache ca-certificates tzdata curl bash postgresql-client \
&& adduser -D -H -u 10001 appuser
CMD ["npx", "serve", ".next/server/app", "-l", "3000"]
WORKDIR /app
COPY --from=builder /app/lti-api /app/lti-api
COPY --from=builder /app/lti-seed /app/lti-seed
USER appuser
EXPOSE 8081
CMD ["/app/lti-api"]