diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3a5a25d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +node_modules +.output +.git +.env* +.DS_Store +*.log diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c19a3ab..043e7dd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,30 +7,41 @@ on: workflow_dispatch: permissions: - contents: write - packages: write + contents: write + packages: write jobs: release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 with: - fetch-depth: 0 - - uses: actions/setup-go@v5 + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 with: - go-version: 1.22 - cache: true - - uses: ko-build/setup-ko@v0.7 - - uses: sigstore/cosign-installer@v3.7.0 + images: ghcr.io/${{ github.repository }} + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha + + - name: Build and push Docker image + uses: docker/build-push-action@v5 with: - cosign-release: v2.2.3 - - uses: goreleaser/goreleaser-action@v5 - with: - version: v1.24.0 - args: release --clean - env: - GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' - COSIGN_PASSWORD: '${{ secrets.COSIGN_PASSWORD }}' - COSIGN_PRIVATE_KEY: '${{ secrets.COSIGN_PRIVATE_KEY }}' - COSIGN_PUBLIC_KEY: '${{ secrets.COSIGN_PUBLIC_KEY }}' + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7461e5d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +# Stage 1 — deps + build +FROM oven/bun:1 AS builder +WORKDIR /app + +COPY package.json bun.lock ./ +RUN bun install --frozen-lockfile + +COPY . . +RUN bun run build + +# Stage 2 — production runtime +FROM node:22-alpine AS runner +WORKDIR /app + +COPY --from=builder /app/.output ./.output + +EXPOSE 3000 + +ENV NODE_ENV=production + +CMD ["node", ".output/server/index.mjs"]