Skip to content

Commit

Permalink
Merge pull request #9 from JacobTheEldest/AddCIDockerBuild
Browse files Browse the repository at this point in the history
Add CI Docker Build
  • Loading branch information
JacobTheEldest authored May 11, 2023
2 parents 4a27571 + 939a1a2 commit ab67d92
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build Docker image and Publish to Github Container Registry

on:
push:
tags: ['v*.*.*']

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
jacobtheeldest/minesweeper
ghcr.io/jacobtheeldest/minesweeper
tags: |
type=semver,pattern={{version}}
type=sha
# tags: |
# type=schedule
# type=ref,event=branch
# type=ref,event=pr
# type=semver,pattern={{version}}
# type=semver,pattern={{major}}.{{minor}}
# type=semver,pattern={{major}}
# type=sha

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Login to GitHub registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
cache-from: type=registry,ref=jacobtheeldest/minesweeper:buildcache
cache-to: type=registry,ref=jacobtheeldest/minesweeper:buildcache,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:lts-alpine3.17

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 3000

CMD [ "npm", "start" ]

0 comments on commit ab67d92

Please sign in to comment.