diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8cc4b36 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_modules +coldmfa/app/node_modules +public/coldmfa +compose diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..91d710d --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,55 @@ +name: Release + +on: + create: + tags: + - v* + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + attestations: write + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + id: push + uses: docker/build-push-action@6 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v1 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true + + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d2ef83d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM golang:1.22-alpine AS builder + +WORKDIR /locus + +COPY go.mod go.sum ./ + +RUN go mod download + +RUN apk update && apk add --update nodejs npm + +COPY locus.go ./ +COPY public public +COPY auth auth +COPY coldmfa coldmfa + +WORKDIR /locus/coldmfa/app +RUN npm ci && npm run build + +WORKDIR /locus + +RUN go build + +FROM alpine:latest + +WORKDIR /app + +COPY --from=builder /locus/locus /app/locus + +EXPOSE 3000 + +CMD ["/app/locus"]