Skip to content

Commit 9191134

Browse files
tuturdAlbanSdl
andauthored
Feat/test ci (#27)
Co-authored-by: AlbanSdl <alban.delavoreille@free.fr>
1 parent 4c71852 commit 9191134

File tree

3 files changed

+92
-1
lines changed

3 files changed

+92
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [master, dev]
5+
pull_request:
6+
branches: [master, dev]
7+
8+
jobs:
9+
lint:
10+
runs-on: self-hosted
11+
strategy:
12+
matrix:
13+
node-version: [18]
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: pnpm/action-setup@v4
17+
with:
18+
version: 9
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
cache: 'pnpm'
24+
- run: pnpm install --frozen-lockfile
25+
- run: pnpm lint
26+
27+
deploy-dev:
28+
if: ${{ github.event_name != 'pull_request' && (github.ref == 'refs/heads/dev') }}
29+
runs-on: self-hosted
30+
needs:
31+
- lint
32+
steps:
33+
- uses: actions/checkout@v4
34+
- name: Install docker
35+
uses: docker/setup-buildx-action@v3
36+
- name: Login to registry
37+
uses: docker/login-action@v3
38+
with:
39+
registry: ${{ secrets.REGISTRY_URL }}
40+
username: ${{ secrets.REGISTRY_USERNAME }}
41+
password: ${{ secrets.REGISTRY_TOKEN }}
42+
- run: cp .env.dist .env.prod
43+
- name: Build and push
44+
uses: docker/build-push-action@v6
45+
with:
46+
push: true
47+
build-args: |
48+
NODE_ENV=production
49+
NEXT_PUBLIC_API_URL=https://etu.dev.uttnetgroup.fr/api
50+
NEXT_PUBLIC_CAS_SERVICE_URL=https://etu.dev.uttnetgroup.fr/login
51+
NEXT_PUBLIC_API_VERSION=v1
52+
NEXT_PUBLIC_API_REQUEST_TIMEOUT=5000
53+
tags: |
54+
${{ secrets.REGISTRY_URL }}/etuutt/front:dev
55+
56+
deploy-prod:
57+
if: ${{ github.event_name != 'pull_request' && (github.ref == 'refs/heads/master') }}
58+
runs-on: self-hosted
59+
needs:
60+
- lint
61+
steps:
62+
- uses: actions/checkout@v4
63+
- name: Install docker
64+
uses: docker/setup-buildx-action@v3
65+
- name: Login to registry
66+
uses: docker/login-action@v3
67+
with:
68+
registry: ${{ secrets.REGISTRY_URL }}
69+
username: ${{ secrets.REGISTRY_USERNAME }}
70+
password: ${{ secrets.REGISTRY_TOKEN }}
71+
- run: cp .env.dist .env.prod
72+
- name: Build and push
73+
uses: docker/build-push-action@v6
74+
with:
75+
push: true
76+
build-args: |
77+
NODE_ENV=production
78+
NEXT_PUBLIC_API_URL=https://etu.utt.fr/api
79+
NEXT_PUBLIC_CAS_SERVICE_URL=https://etu.utt.fr/login
80+
NEXT_PUBLIC_API_VERSION=v1
81+
NEXT_PUBLIC_API_REQUEST_TIMEOUT=5000
82+
tags: |
83+
${{ secrets.REGISTRY_URL }}/etuutt/front:prod

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
ARG NODE_VERSION=19-alpine
1+
ARG NODE_VERSION=22-alpine
22

33
FROM node:${NODE_VERSION}
44

55
WORKDIR /usr/src/app
66

7+
# Add alpine dependencies for 'sharp'
8+
RUN apk add --upgrade --no-cache vips-dev build-base
9+
710
COPY --chown=node:node package.json pnpm-lock.yaml ./
811

912
RUN npm i -g pnpm && pnpm install --frozen-lockfile --prod=false

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,10 @@
4747
"eslint-plugin-react": "^7.34.2",
4848
"sass": "^1.77.4",
4949
"typescript": "^5.4.5"
50+
},
51+
"pnpm": {
52+
"onlyBuiltDependencies": [
53+
"sharp"
54+
]
5055
}
5156
}

0 commit comments

Comments
 (0)