diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e1e9573c..afcc082d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,7 +15,7 @@ default: # ========================================================== .build_template: &build_template stage: build - image: node:20-alpine + image: public.ecr.aws/docker/library/node:20-alpine cache: key: npm-cache paths: @@ -56,7 +56,7 @@ default: .deploy_template: &deploy_template stage: deploy image: - name: amazon/aws-cli:latest + name: public.ecr.aws/aws-cli/aws-cli:latest entrypoint: ['/bin/sh', '-c'] script: - set -e diff --git a/Dockerfile b/Dockerfile index 32e0688d..ff968b26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,25 @@ -# ========================= -# Builder stage -# ========================= -FROM golang:1.23-alpine AS builder +FROM public.ecr.aws/docker/library/node:20-alpine + +RUN apk add --no-cache git bash build-base curl -RUN apk add --no-cache git ca-certificates tzdata WORKDIR /app -COPY go.mod go.sum ./ -RUN go mod download +COPY package*.json ./ +RUN npm ci COPY . . -# Build API binary -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \ - go build -trimpath -ldflags="-s -w" -o lti-api ./cmd/api +# Buat config agar Next tahu output: export +RUN echo "const config = { output: 'export', images: { unoptimized: true } }; export default config;" > next.config.mjs -# 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 +# Build project (Next.js 15 otomatis static export) +RUN NEXT_DISABLE_TURBOPACK=1 npx next build -# ========================= -# Runtime stage -# ========================= -FROM alpine:3.20 +# 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/ -RUN apk add --no-cache ca-certificates tzdata curl bash postgresql-client \ - && adduser -D -H -u 10001 appuser +EXPOSE 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"] +CMD ["npx", "serve", ".next/server/app", "-l", "3000"] diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 00000000..b89f441b --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,39 @@ +version: '3.9' + +services: + dev-web-lti: + container_name: dev-web-lti + build: + context: . + dockerfile: Dockerfile + ports: + - '3002:3000' + env_file: + - .env + environment: + NODE_ENV: production + APP_ENV: production + networks: + - dev-lti-network + restart: always + deploy: + resources: + limits: + cpus: '3.0' + memory: 3G + reservations: + cpus: '1.0' + memory: 512M + extra_hosts: + - 'host.docker.internal:host-gateway' + # Optional: aktifkan healthcheck jika punya endpoint + # healthcheck: + # test: ["CMD-SHELL", "curl -fsS http://localhost:3000/api/healthz || exit 1"] + # interval: 10s + # timeout: 3s + # retries: 10 + # start_period: 15s + +networks: + dev-lti-network: + external: true