Skip to content
Snippets Groups Projects
Unverified Commit e48f7042 authored by BITARD Michaël's avatar BITARD Michaël Committed by GitHub
Browse files

chore(infra): la ci build l'api en parallèle (#291)

parent 2977acb8
No related branches found
No related tags found
No related merge requests found
......@@ -9,3 +9,8 @@ infra/cd/.cargo_docker
infra/cd/target
packages/api/backups
packages/api/sources
packages/api/files
packages/api/api-cache
packages/api/coverage
packages/api/docs
packages/ui/coverage
\ No newline at end of file
......@@ -12,6 +12,20 @@ on:
description: 'le token docker'
required: true
jobs:
type:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '19.1'
cache: 'npm'
- name: Npm install
run: make install
- name: Build
run: make build/api
lint:
runs-on: ubuntu-latest
steps:
......@@ -85,7 +99,7 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
flags: api-integration, api
build:
needs: [unit-test, integration-test, lint]
needs: [unit-test, integration-test, lint, type]
runs-on: ubuntu-latest
steps:
......
FROM node:19.1-alpine as build-stage
WORKDIR /app
FROM node:19.1-alpine
WORKDIR /
RUN apk add make
COPY package*.json /app/
COPY packages/common/package.json /app/packages/common/package.json
COPY packages/api/package.json /app/packages/api/package.json
COPY Makefile /app/Makefile
RUN CI=true make install
COPY ./ /app/
RUN npm run build -w packages/api && \
rm -rf /app/node_modules/ && \
rm -rf /app/packages/api/node_modules/ && \
rm -rf /app/packages/ui/node_modules/ && \
rm -rf /app/packages/common/node_modules/ && \
CI=true make install/prod
FROM node:19.1-alpine as production-stage
# TODO 2022-07-13 : on profite que
# - l'utilisateur a le même id sur toutes les machines
# - ansible crée les dossiers avec les bons droits
RUN apk add make && adduser -u 1002 -D nonroot
USER nonroot
COPY --chown=nonroot:nonroot --from=build-stage /app/package.json ./
COPY --chown=nonroot:nonroot --from=build-stage /app/packages/api/package.json ./packages/api/
COPY --chown=nonroot:nonroot --from=build-stage /app/packages/common/package.json ./packages/common/
COPY --chown=nonroot:nonroot --from=build-stage /app/node_modules ./node_modules/
COPY --chown=nonroot:nonroot --from=build-stage /app/packages/api/node_modules /packages/api/node_modules/
COPY --chown=nonroot:nonroot --from=build-stage /app/packages/api/src ./packages/api/src/
COPY --chown=nonroot:nonroot --from=build-stage /app/packages/api/tsconfig.json ./packages/api/
COPY --chown=nonroot:nonroot --from=build-stage /app/packages/common/src ./packages/common/src/
COPY --chown=nonroot:nonroot --from=build-stage /app/packages/common/tsconfig.json ./packages/common/
COPY --chown=nonroot:nonroot Makefile .
# Ce n'est pas nécessaire pour les environnements de prod (le dossier est crée par ansible et monté) mais est plus correct pour pouvoir utiliser l'image sans problème de droit au démarrage
RUN mkdir -p /packages/api/files
CMD ["make", "start/api"]
COPY ./package-lock.json /
COPY ./Makefile /Makefile
COPY ./package.json /
COPY ./packages/api/ /packages/api
COPY ./packages/common/ /packages/common
RUN CI=true make install/prod
ENTRYPOINT ["make", "start/api"]
\ No newline at end of file
......@@ -52,16 +52,16 @@ endif
install:
ifdef CI
npm set-script prepare ""
npm pkg delete scripts
endif
npm ci
install/prod:
ifdef CI
npm set-script prepare ""
npm pkg delete scripts
endif
npm ci --only=prod
npm ci --omit=dev
build: build/common build/api build/ui
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment