Skip to content
Snippets Groups Projects
Commit 63829f3d authored by Bilel El Yaagoubi's avatar Bilel El Yaagoubi
Browse files

Configure CI

parent 9686c9c4
No related branches found
No related tags found
1 merge request!3Configure CI
stages:
- lint
- build
.eslint:
image: node:16.14.0-alpine
stage: lint
script:
- cd $CONTEXT
# install packages
- npm install
# Run eslint
- npm run lint
.build:
stage: build
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_BRANCH
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- if [ $CI_COMMIT_BRANCH = $CI_DEFAULT_BRANCH ] ; then
- TAG="latest" ; else
- TAG=$CI_COMMIT_BRANCH ; fi
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "robot\$${REGISTRY_USERNAME}" "${REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- >-
/kaniko/executor
--context $CONTEXT
--dockerfile $CONTEXT/Dockerfile
--destination "${REGISTRY}/$IMAGE_NAME:${TAG}"
--cache
lint-front:
extends: .eslint
variables:
CONTEXT: frontend/
lint-back:
extends: .eslint
variables:
CONTEXT: backend/
build-front:
extends: .build
variables:
CONTEXT: frontend/
IMAGE_NAME: front
build-back:
allow_failure: true
extends: .build
variables:
CONTEXT: backend/
IMAGE_NAME: back
.dockerignore
.env.example
.eslintrc.js
Dockerfile
.gitignore
FROM node:12.4
WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN touch .env
EXPOSE 3000
ENTRYPOINT echo "PORT=$PORT" >> .env && echo "NODE_ENV=$NODE_ENV" >> .env \
&& echo "MONGO_DB_URL=$MONGO_DB_URL" >> .env && node server.js
\ No newline at end of file
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
"scripts": { "scripts": {
"dev": "dotenv nodemon ./server.js", "dev": "dotenv nodemon ./server.js",
"start": "dotenv node ./server.js", "start": "dotenv node ./server.js",
"lint": "eslint . --fix" "lint": "eslint . ",
"format": "eslint . --fix"
}, },
"dependencies": { "dependencies": {
"cors": "^2.8.5", "cors": "^2.8.5",
......
.dockerignore
.env.development
.eslintrc.js
.prettierrc
Dockerfile
node_modules
dist
\ No newline at end of file
...@@ -5,3 +5,4 @@ node_modules ...@@ -5,3 +5,4 @@ node_modules
# local env files # local env files
.env.local .env.local
.env.*.local .env.*.local
.env
\ No newline at end of file
FROM node:16 as build
WORKDIR /frontend
COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN touch .env
RUN echo "VUE_APP_BACKEND_BASE_URL=webroot.example.com" >> .env
RUN npm run build
FROM nginxinc/nginx-unprivileged:latest
COPY --chown=nginx --from=build /frontend/dist/ /usr/share/nginx/html
ENTRYPOINT sed -i -e "s/webroot.example.com/$VUE_APP_BACKEND_BASE_URL/g" /usr/share/nginx/html/js/app.*.js \
&& nginx -g 'daemon off;'
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment