Skip to content

Commit bf1e5c2

Browse files
committed
fix: add true docker support
1 parent 6f55264 commit bf1e5c2

File tree

5 files changed

+442
-195
lines changed

5 files changed

+442
-195
lines changed

.github/workflows/release.yml

Lines changed: 83 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,103 @@
1-
name: Release
1+
name: Docker
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
27

38
on:
9+
schedule:
10+
- cron: '41 6 * * *'
411
push:
512
branches:
613
- master
714

815
env:
9-
DOCKER_IMAGE_NAME: mergeability/mergeable
16+
# Use docker.io for Docker Hub if empty
17+
REGISTRY: ghcr.io
18+
# github.repository as <account>/<repo>
19+
IMAGE_NAME: ${{ github.repository }}
20+
1021

1122
jobs:
1223
build:
13-
name: Release
24+
1425
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
28+
packages: write
29+
# This is used to complete the identity challenge
30+
# with sigstore/fulcio when running outside of PRs.
31+
id-token: write
32+
1533
steps:
16-
- name: Checkout
34+
- name: Checkout repository
1735
uses: actions/checkout@v4
36+
37+
# Install the cosign tool except on PR
38+
# https://github.com/sigstore/cosign-installer
39+
- name: Install cosign
40+
if: github.event_name != 'pull_request'
41+
uses: sigstore/cosign-installer@4959ce089c160fddf62f7b42464195ba1a56d382 # v3.6.0
42+
with:
43+
cosign-release: 'v2.2.4'
44+
45+
# Get release version information from github commits
1846
- name: Semantic Release
1947
id: semantic
2048
uses: cycjimmy/semantic-release-action@v4
2149
env:
2250
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
24-
- name: Login to Docker Hub
25-
uses: docker/login-action@v3
51+
52+
# Set up BuildKit Docker container builder to be able to build
53+
# multi-platform images and export cache
54+
# https://github.com/docker/setup-buildx-action
55+
- name: Set up Docker Buildx
56+
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
57+
58+
# Login against a Docker registry except on PR
59+
# https://github.com/docker/login-action
60+
- name: Log into registry ${{ env.REGISTRY }}
61+
if: github.event_name != 'pull_request'
62+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
2663
with:
27-
username: ${{ secrets.DOCKERHUB_USERNAME }}
28-
password: ${{ secrets.DOCKERHUB_TOKEN }}
29-
if: ${{ steps.semantic.outputs.new_release_version }}
30-
- uses: buildpacks/github-actions/[email protected]
31-
if: ${{ steps.semantic.outputs.new_release_version }}
32-
- name: Build and publish docker image
64+
registry: ${{ env.REGISTRY }}
65+
username: ${{ github.actor }}
66+
password: ${{ secrets.GITHUB_TOKEN }}
67+
68+
# Extract metadata (tags, labels) for Docker
69+
# https://github.com/docker/metadata-action
70+
- name: Extract Docker metadata
71+
id: meta
72+
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
73+
with:
74+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
75+
76+
# Build and push Docker image with Buildx (don't push on PR)
77+
# https://github.com/docker/build-push-action
78+
- name: Build and push Docker image
3379
if: ${{ steps.semantic.outputs.new_release_version }}
34-
run: pack build ${{ env.DOCKER_IMAGE_NAME }} -t ${{ env.DOCKER_IMAGE_NAME }}:${{ steps.semantic.outputs.new_release_version }} -t ${{ env.DOCKER_IMAGE_NAME }}:latest -B paketobuildpacks/builder-jammy-tiny -b docker.io/paketobuildpacks/nodejs --publish
80+
id: build-and-push
81+
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0
82+
with:
83+
context: .
84+
push: ${{ github.event_name != 'pull_request' }}
85+
tags: ${{ steps.semantic.outputs.new_release_version }}
86+
labels: ${{ steps.meta.outputs.labels }}
87+
cache-from: type=gha
88+
cache-to: type=gha,mode=max
89+
90+
# Sign the resulting Docker image digest except on PRs.
91+
# This will only write to the public Rekor transparency log when the Docker
92+
# repository is public to avoid leaking data. If you would like to publish
93+
# transparency data even for private images, pass --force to cosign below.
94+
# https://github.com/sigstore/cosign
95+
- name: Sign the published Docker image
96+
if: ${{ github.event_name != 'pull_request' }}
97+
env:
98+
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
99+
TAGS: ${{ steps.meta.outputs.tags }}
100+
DIGEST: ${{ steps.build-and-push.outputs.digest }}
101+
# This step uses the identity token to provision an ephemeral certificate
102+
# against the sigstore community Fulcio instance.
103+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ coverage
5858
/coverage_*
5959
/artifacts
6060
.DS_Store
61+
*.old
6162
jsconfig.json
6263
/test-reports
6364
/cypress/videos

dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) 2024 Nordic Game Lab, LLC. All rights reserved
2+
# Base image
3+
FROM node:20.17.0-alpine
4+
5+
LABEL org.opencontainers.image.vendor="Nordic Game Lab, LLC"
6+
LABEL org.opencontainers.image.licenses=AGPL-3.0-only
7+
8+
# Set working directory
9+
WORKDIR /app
10+
11+
# Copy package.json, package-lock.json, and source code
12+
COPY package*.json ./
13+
14+
# Install dependencies using yarn
15+
RUN npm install
16+
17+
# Copy remaining source code
18+
COPY . .
19+
20+
# Expose port 3000
21+
EXPOSE 3000
22+
23+
# Start the application
24+
CMD ["npm", "start"]

0 commit comments

Comments
 (0)