From 72925ffd0c342cb1b95f26c0650029b52a06dd35 Mon Sep 17 00:00:00 2001 From: DataHearth Date: Thu, 29 Jun 2023 14:57:02 +0200 Subject: [PATCH] update image --- .dockerignore | 3 +- .env => .env.template | 0 .gitea/workflows/deploy.yml | 59 ++++++++++++++++++------------------- .gitignore | 1 + Dockerfile | 13 +++----- ecosystem.config.js | 2 ++ entrypoint.sh | 4 +-- 7 files changed, 38 insertions(+), 44 deletions(-) rename .env => .env.template (100%) create mode 100644 .gitignore diff --git a/.dockerignore b/.dockerignore index 2b938b3..53ee560 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,4 @@ Dockerfile .dockerignore LICENSE -.gitea -.git \ No newline at end of file +.git* \ No newline at end of file diff --git a/.env b/.env.template similarity index 100% rename from .env rename to .env.template diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 5489d80..33b3fbc 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -6,15 +6,16 @@ on: - "v*[0-9].*[0-9].*[0-9]?(-rc?(.*[0-9])|-dev?(.*[0-9]))" - latest +env: + REPOSITORY: dataheath/reactive-resume + HOSTNAME: gitea.antoine-langlois.net + jobs: deploy: - runs-on: ubuntu-latest - container: docker:latest + runs-on: debian-docker steps: - - name: Set up NodeJS - run: | - apk update - apk add nodejs npm + - name: Checkout + uses: actions/checkout@v3 - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -31,48 +32,46 @@ jobs: - name: Login to Gitea Container Registry uses: docker/login-action@v2 with: - registry: gitea.antoine-langlois.net + registry: ${{ env.HOSTNAME }} username: ${{ gitea.repository_owner }} password: ${{ secrets.REGISTRY_TOKEN }} - - name: Get latest version - id: get_lts - if: ${{ gitea.ref_name == 'latest' }} + - name: Fetch remote repository + id: fetch_version run: | - apk add jq curl - echo "version=$(curl -sfL https://api.github.com/repos/AmruthPillai/Reactive-Resume/releases/latest | jq .tag_name -r)" >> $GITHUB_OUTPUT + apt-get install -y jq + if [[ ${{ gitea.ref_name }} == 'latest' ]]; do \ + export VERSION=$(curl -sfL https://api.github.com/repos/AmruthPillai/Reactive-Resume/releases/latest | jq .tag_name -r); \ + else \ + export VERSION=${{ gitea.ref_name }}; \ + fi - - name: Checkout - # todo: uncomment when checkout support other git servers - # uses: actions/checkout@v3 - run: | - apk add git - git clone --depth 1 --branch ${{ gitea.ref_name }} https://gitea.antoine-langlois.net/${{ gitea.repository }}.git . + git clone --depth 1 --branch $VERSION https://github.com/AmruthPillai/Reactive-Resume.git app + + echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Build and push latest uses: docker/build-push-action@v4 if: ${{ gitea.ref_name == 'latest' }} with: context: . - platforms: linux/amd64,linux/arm64 - build-args: | - VERSION=${{ steps.get_lts.outputs.version }} push: true + cache-to: type=inline + cache-from: type=registry,ref=${{ env.REPOSITORY}} tags: | - datahearth/reactive-resume:${{ steps.get_lts.outputs.version }} - datahearth/reactive-resume:latest - gitea.antoine-langlois.net/dataheath/reactive-resume:${{ steps.get_lts.outputs.version }} - gitea.antoine-langlois.net/dataheath/reactive-resume:latest + ${{ env.REPOSITORY }}:${{ steps.get_version.outputs.version }} + ${{ env.REPOSITORY }}:latest + ${{ env.HOSTNAME }}/${{ env.REPOSITORY }}:${{ steps.get_version.outputs.version }} + ${{ env.HOSTNAME }}/${{ env.REPOSITORY }}:latest - name: Build and push tag uses: docker/build-push-action@v4 if: ${{ gitea.ref_name != 'latest' }} with: context: . - platforms: linux/amd64,linux/arm64 - build-args: | - VERSION=${{ gitea.ref_name }} + platforms: linux/amd64 push: true + cache-from: type=registry,ref=${{ env.REPOSITORY }}:latest tags: | - datahearth/reactive-resume:${{ gitea.ref_name } - gitea.antoine-langlois.net/datahearth/reactive-resume:${{ gitea.ref_name }} + ${{ env.REPOSITORY }}:${{ steps.get_version.outputs.version } + ${{ env.HOSTNAME }}/${{ env.REPOSITORY }}:${{ steps.get_version.outputs.version }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7a0b7f0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +app \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index fe5ad5b..ae4c26a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,8 @@ -FROM node:lts-bullseye-slim - -ARG VERSION - -RUN apt-get update -RUN apt-get install -y git +FROM mcr.microsoft.com/playwright:v1.35.1-jammy RUN npm install -g pnpm pm2 -RUN git clone --depth 1 --branch ${VERSION} https://github.com/AmruthPillai/Reactive-Resume.git /app +COPY app /app WORKDIR /app @@ -15,9 +10,9 @@ ENV NEXT_TELEMETRY_DISABLED=1 RUN pnpm install --frozen-lockfile RUN pnpm build -RUN npx playwright install-deps +RUN pnpm dlx playwright install --with-deps chromium -COPY .env /data/.env.template +COPY .env.template /data/.env.template COPY entrypoint.sh /data/entrypoint.sh COPY ecosystem.config.js /data/ecosystem.config.js diff --git a/ecosystem.config.js b/ecosystem.config.js index 140ac0d..d26a8c2 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -3,10 +3,12 @@ module.exports = [ script: "pnpm --filter server start", cwd: "/app", name: "server", + max_restarts: 3, }, { script: "pnpm --filter client start", cwd: "/app", name: "client", + max_restarts: 3, }, ]; diff --git a/entrypoint.sh b/entrypoint.sh index e919f7f..320a5b0 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,8 +4,6 @@ if [ ! -f .env ]; then cp /data/.env.template .env fi -set -a -source .env -set +a +export $(grep -v '^#' .env | xargs) exec "$@" \ No newline at end of file