From 5bd625b659c2cf0c7d67ed6fa6064012e1ebd541 Mon Sep 17 00:00:00 2001 From: nyaruta <168252381+nyaruta@users.noreply.github.com> Date: Thu, 6 Jun 2024 02:44:24 +0000 Subject: [PATCH] feat: Prebuilt Docker Image --- .github/workflows/docker.yml | 55 ++++++++++++++++++++++++++++++++++++ Dockerfile | 15 +++++----- 2 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..11992c5 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,55 @@ +name: Docker + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest + type=ref,event=tag + type=sha + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 87595e8..10c7aad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,10 @@ -FROM nikolaik/python-nodejs:python3.8-nodejs12 AS builder +FROM node:20-alpine3.16 -ENV NODE_WORKDIR /app -WORKDIR $NODE_WORKDIR +WORKDIR /app +ADD . /app -ADD . $NODE_WORKDIR +RUN apk add gcompat libstdc++ libuuid vips-dev build-base jpeg-dev pango-dev cairo-dev imagemagick libssl1.1 --no-cache&& \ +ln -s /lib/libresolv.so.2 /usr/lib/libresolv.so.2 +RUN npm install -RUN apt-get update && apt-get install -y build-essential gcc wget git libvips && rm -rf /var/lib/apt/lists/* - - -RUN npm install canvas@2.6.1 && npm install # TODO: canvas crashes if installed via npm install from package.json \ No newline at end of file +CMD ["index.js"]