From 4906b1dddebde77f3a2021868a3cffc5c2b6a528 Mon Sep 17 00:00:00 2001 From: legonzaur Date: Sun, 1 Jun 2025 13:13:23 +0200 Subject: [PATCH] fix build --- .gitea/workflows/build.yml | 49 ++++++++++++++++++++++++++++++++++++++ Containerfile | 22 +++++++++++++++++ src/main.ts | 2 ++ 3 files changed, 73 insertions(+) create mode 100644 .gitea/workflows/build.yml create mode 100644 Containerfile diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..2aeb7d8 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,49 @@ +name: release-tag + +on: + push: + tags: + - '**' + +jobs: + release-image: + runs-on: ubuntu-latest + + env: + REPO_NAME: ${{ gitea.repository }} + ENDPOINT: git.legonzaur.fr + + steps: + - name: Checkout + uses: actions/checkout@v4 + + # - 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: ./Containerfile + build-args: | + NUXT_PUBLIC_API_BASE=${{ vars.NUXT_PUBLIC_API_BASE }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..b7878de --- /dev/null +++ b/Containerfile @@ -0,0 +1,22 @@ +FROM node:lts-alpine AS build-stage +WORKDIR /app +COPY package*.json ./ +RUN npm ci +COPY . . +RUN npx nest build + +# étape de production +FROM node:lts-alpine AS production-stage +WORKDIR /app +COPY --from=build-stage /app/dist/ /app +COPY --from=build-stage /app/node_modules/ /app/node_modules +EXPOSE 3000 + +ENV API_PREFIX=/api + +ENV PG_HOST=127.0.0.1 +ENV PG_USER=polls +ENV PG_PASSWORD=polls +ENV PG_DATABASE=polls + +CMD ["node", "main"] \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 535001b..9007eaa 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,6 +9,8 @@ async function bootstrap() { app.useGlobalPipes(new ValidationPipe()); app.enableCors({ origin: '*' }); + app.setGlobalPrefix(process.env.API_PREFIX ?? ''); + const config = new DocumentBuilder() .setTitle('Vote au jugement majoritaire') .setDescription('API description')