From aa4c6edc65b739152021a1d92214d241d9cf1179 Mon Sep 17 00:00:00 2001 From: legonzaur Date: Fri, 2 Aug 2024 10:52:50 +0200 Subject: [PATCH] ci : initial configuration --- .gitea/workflows/build.yml | 66 ++++++++++++++++++++++++++++++++++++++ Dockerfile | 11 +++++++ 2 files changed, 77 insertions(+) create mode 100644 .gitea/workflows/build.yml create mode 100644 Dockerfile diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..8137cc6 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,66 @@ +name: release-tag + +on: + push: + +jobs: + release-image: + runs-on: ubuntu-latest + + env: + REPO_NAME: ${{ gitea.repository }} + ENDPOINT: git.legonzaur.fr + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + lfs: false + persist-credentials: false + + - name: setup private key + shell: bash + run: | + echo "${{ secrets.RUNNER_SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519 + chmod 400 ~/.ssh/id_ed25519 + echo "{{ secrets.INSTANCE_SSH_PUBLIC_KEY }} > ~/.ssh/known_hosts" + + - name: git lfs pull + shell: bash + run: | + ssh-keyscan ${{ env.ENDPOINT }} >> ~/.ssh/known_hosts + git remote set-url origin git@${{ env.ENDPOINT }}:${{ env.REPO_NAME }}.git + git lfs pull + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + registry: ${{ env.ENDPOINT }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.ENDPOINT }}/${{ env.REPO_NAME }} + tags: | + type=schedule + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + build-args: | + NUXT_PUBLIC_ENDPOINT=${{ vars.NUXT_PUBLIC_ENDPOINT }} + NUXT_PUBLIC_DISCORD_LOGIN_ENDPOINT=${{ vars.NUXT_PUBLIC_DISCORD_LOGIN_ENDPOINT }} + NUXT_PUBLIC_WELCOME_MESSAGE=${{ vars.NUXT_PUBLIC_WELCOME_MESSAGE }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a838867 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM python:alpine3.19 AS build-stage +WORKDIR /app +ENV VIRTUAL_ENV=/opt/venv +RUN python3 -m venv $VIRTUAL_ENV +ENV PATH="$VIRTUAL_ENV/bin:$PATH" +COPY requirements.txt ./ +RUN pip install -r requirements.txt + +# étape de production +COPY src ./src +CMD ["python3", "-u", "./src/generate_cards_mvp.py"] \ No newline at end of file