Skip to content

Commit

Permalink
Add docker image (#550)
Browse files Browse the repository at this point in the history
* Add docker image

* Ignore hadolint warning

Ref. https://github.com/hadolint/hadolint/wiki/DL3008

* Fix CMD

* Update .github/workflows/docker.yml

Co-authored-by: Adonys Santos <58638286+adonyssantos@users.noreply.github.com>

* Set node version to 20

---------

Co-authored-by: Adonys Santos <58638286+adonyssantos@users.noreply.github.com>
  • Loading branch information
tmaier and adonyssantos authored Jan 31, 2025
1 parent b326606 commit b293be4
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Create and publish a Docker image

on:
push:
branches:
- master

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

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

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM node:20-slim

ARG CRITICAL_VERSION=5.0.4

ARG PACKAGES="\
libx11-6\
libx11-xcb1\
libxcomposite1\
libxcursor1\
libxdamage1\
libxext6\
libxi6\
libxtst6\
libglib2.0-0\
libnss3\
libcups2\
libxss1\
libexpat1\
libxrandr2\
libasound2\
libatk1.0-0\
libatk-bridge2.0-0\
libpangocairo-1.0-0\
libgtk-3-0\
"
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
# hadolint ignore=DL3008
RUN --mount=type=cache,id=build-apt-cache,sharing=locked,target=/var/cache/apt \
--mount=type=cache,id=build-apt-lib,sharing=locked,target=/var/lib/apt \
apt-get update -qq \
&& apt-get install --no-install-recommends -y ${PACKAGES} \
&& rm -rf /var/lib/apt/lists /var/cache/apt/archives

RUN --mount=type=cache,id=build-npm-cache,sharing=locked,target=/root/.npm \
npm install -g critical@${CRITICAL_VERSION}

WORKDIR /site

CMD ["critical", "--help"]

0 comments on commit b293be4

Please sign in to comment.