From d7a4ad196bee73eb634006eed436c8c5180e0ab9 Mon Sep 17 00:00:00 2001 From: Fascinated Date: Sat, 8 Jul 2023 20:49:08 +0100 Subject: [PATCH] move to dockerhub image --- .gitea/workflows/upload-image.yaml | 82 ++++++++++++++++++++++++++++++ Dockerfile | 1 + docker-compose.yml | 10 ++-- 3 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 .gitea/workflows/upload-image.yaml diff --git a/.gitea/workflows/upload-image.yaml b/.gitea/workflows/upload-image.yaml new file mode 100644 index 0000000..2aa66fd --- /dev/null +++ b/.gitea/workflows/upload-image.yaml @@ -0,0 +1,82 @@ +name: Publish Docker Image + +on: + push: + branches: + - "master" + - "development" + paths-ignore: # Files in here will not trigger a build + - "README.md" + - "sharex.sxcu" + - "LICENSE" + - "docker-compose.yml" + +jobs: + docker: + runs-on: ubuntu-20.04 + steps: + - name: Get branch name + id: branch-name + uses: tj-actions/branch-names@v7 + + - name: Checkout + uses: actions/checkout@v3 + + - name: Restore Docker Cache + uses: actions/cache@v3 + id: docker-cache + with: + path: /usr/bin/docker + key: ${{ runner.os }}-docker + + - name: Install Docker (if not cached) + if: steps.docker-cache.outputs.cache-hit != 'true' + run: | + wget -q -O /tmp/docker.tgz https://download.docker.com/linux/static/stable/x86_64/docker-20.10.23.tgz \ + && tar --extract --file /tmp/docker.tgz --directory /usr/bin --strip-components 1 --no-same-owner docker/docker \ + && rm -rf /tmp/* && + echo "Done" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Repo + uses: docker/login-action@v2 + with: + username: ${{ secrets.REPO_USERNAME }} + password: ${{ secrets.REPO_TOKEN }} + + - name: Restore Docker Build Cache + uses: actions/cache@v3 + id: build-cache + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx + + - name: Build and Push (Latest) + uses: docker/build-push-action@v4 + if: steps.branch-name.outputs.current_branch == 'master' + with: + push: true + context: . + tags: fascinated/simple-links:latest + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and Push (Other Branches) + uses: docker/build-push-action@v4 + if: steps.branch-name.outputs.current_branch != 'master' + with: + push: true + context: . + tags: fascinated/simple-links:${{ steps.branch-name.outputs.current_branch }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Save Docker Build Cache + if: steps.build-cache.outputs.cache-hit != 'true' + run: | + mkdir -p /tmp/.buildx-cache + cp -r /tmp/.buildx-cache/. /tmp/.buildx-cache-new + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache diff --git a/Dockerfile b/Dockerfile index b99e390..f05a43b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM node:lts-alpine + ENV NODE_ENV=production WORKDIR /usr/src/app COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"] diff --git a/docker-compose.yml b/docker-compose.yml index 5fe9762..ef7a2b8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,10 +2,12 @@ version: "3.4" services: simple-links: - build: https://git.fascinated.cc/Fascinated/simple-links.git - # Use this below if you want to build the image locally (you need to clone the repo first) - # build: . - # image: fascinated/simple-links + image: fascinated/simple-links:latest + # Uncomment the following line to build the image yourself + # build: https://git.fascinated.cc/Fascinated/simple-links.git + # or build it locally (you need to clone the repo first): + # build: + # context: . restart: always environment: NODE_ENV: production