Skip to content

Commit

Permalink
Add docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan818fr committed Aug 26, 2023
1 parent 69bb462 commit fdc8d70
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Dockerfile
.dockerignore
.env
.git
.gitignore
LICENSE
node_modules
.prettierignore
.prettierrc.yaml
.readme
README.md
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly

- package-ecosystem: npm
directory: /
schedule:
interval: weekly

- package-ecosystem: docker
directory: /
schedule:
interval: weekly
49 changes: 49 additions & 0 deletions .github/workflows/docker-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Docker Image CI

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

env:
IMAGE: ghcr.io/${{ github.repository }}
PROJECT_URL: https://github.com/${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
permissions: write-all # required to push to GitHub Container Registry

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

- name: Login to GitHub Container Registry
run: |
buildah login -u "$REGISTRY_USER" --password-stdin <<<"$REGISTRY_PASSWORD" "${IMAGE%%/*}"
env:
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ github.token }}

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

- name: Build
run: |
set -ex
tags=("${IMAGE}:${GITHUB_REF_NAME}" "${IMAGE}:latest")
buildah build \
--platform linux/amd64,linux/arm64 \
--manifest "${tags[0]}" \
--timestamp="$(git show -s --format=%ct HEAD)" \
--label="org.opencontainers.image.url=${PROJECT_URL}" \
--label="org.opencontainers.image.source=${PROJECT_URL}" \
--label="org.opencontainers.image.version=${GITHUB_REF_NAME}" \
--label="org.opencontainers.image.revision=${GITHUB_SHA}"
for tag in "${tags[@]:1}"; do
buildah tag -- "${tags[0]}" "$tag"
done
for tag in "${tags[@]}"; do
buildah push -- "$tag"
done
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM docker.io/library/node:18.17.1-alpine3.18

ENV NODE_ENV=production

COPY . /app/

WORKDIR /app

RUN npm ci --no-audit --no-fund --logs-dir=/dev/null && { npm cache clean --force --logs-dir=/dev/null || true; }

USER node
CMD [ "node", "/app/src/index.js" ]

0 comments on commit fdc8d70

Please sign in to comment.