Skip to content
Snippets Groups Projects
Commit b880dcb3 authored by FETCHEPING FETCHEPING Rossif Borel's avatar FETCHEPING FETCHEPING Rossif Borel
Browse files

Hadolint: linter dockerfile

parent 3e58c843
No related branches found
No related tags found
1 merge request!3Pipeline complete
Pipeline #7977 failed
......@@ -7,3 +7,4 @@ report.sh
.pytest_cache/
requirements.txt.old
**/node_modules
docker-compose.yml
\ No newline at end of file
image: python:3.8-alpine
workflow:
rules:
- if: $CI_COMMIT_BRANCH == "main"
#workflow:
# rules:
# - if: $CI_COMMIT_BRANCH == "main"
stages: # List of stages for jobs, and their order of execution
- test
......@@ -11,7 +11,7 @@ stages: # List of stages for jobs, and their order of execution
- deploy
#Job de test de qualité de code Python de l'API
lint_test_job:
.lint_test_job:
stage: test
script:
- rm -rf docs/api/lint.md && touch docs/api/lint.md
......@@ -25,7 +25,7 @@ lint_test_job:
#allow_failure: true
#Job de test end to end de l'API
e2e_test_job:
.e2e_test_job:
stage: test
script:
- rm -rf docs/api/unit.md && touch docs/api/unit.md
......@@ -37,7 +37,7 @@ e2e_test_job:
- docs
#Job de test de couverture de code Python de l'API
cov_test_job:
.cov_test_job:
stage: test
script:
- rm -rf docs/api/coverage.md && touch docs/api/coverage.md
......@@ -49,7 +49,7 @@ cov_test_job:
- docs
#Job de test de qualité de code HTML, JS et CSS
front_test_job:
.front_test_job:
image: node:16
stage: test
script:
......@@ -64,6 +64,18 @@ front_test_job:
paths:
- docs
docker_lint:
image: hadolint/hadolint
script:
- rm -rf docs/docker/lint.md && touch docs/docker/lint.md
- echo "##Dockerfile.api" >> docs/docker/lint.md
- hadolint --no-color --no-fail Dockerfile.api | while read line; do echo ${line}" " >> docs/docker/lint.md; done
- echo "##Dockerfile.front" >> docs/docker/lint.md
- hadolint --no-color --no-fail Dockerfile.front | while read line; do echo ${line}" " >> docs/docker/lint.md; done
artifacts:
paths:
- docs
# Job de génération des pages pour le reporting des tests
pages:
stage: report
......@@ -71,10 +83,11 @@ pages:
- pip install mkdocs-material
- mkdocs build -d public
needs:
- job: lint_test_job
- job: e2e_test_job
- job: cov_test_job
- job: front_test_job
#- job: lint_test_job
#- job: e2e_test_job
#- job: cov_test_job
#- job: front_test_job
- job: docker_lint
artifacts:
paths:
- public
......@@ -87,7 +100,7 @@ variables:
TAG_FRONT_LATEST: $CI_REGISTRY_IMAGE/vapormap_front:latest
# Job de build et push des images docker
build:
.build:
stage: build
variables:
DOCKER_TLS_CERTDIR: ""
......@@ -108,7 +121,7 @@ build:
- docker push $TAG_FRONT_LATEST
# Job de deploy des images docker sur la VM avec docker-compose
deploy:
.deploy:
stage: deploy
tags:
- vm-imt
......
......@@ -2,7 +2,8 @@ FROM python:3.8-alpine
WORKDIR /usr/src/app
COPY vapormap/app .
RUN pip install --no-cache-dir -r requirements/production.txt
RUN pip install -r requirements/production.txt
RUN pip install flask
ENTRYPOINT ["flask"]
CMD ["run", "--host=0.0.0.0"]
......
......@@ -3,6 +3,4 @@ FROM nginx:1.23-alpine
WORKDIR /usr/share/nginx/html
COPY vapormap/frontend .
ENTRYPOINT ["nginx"]
CMD ["-g", "daemon off;"]
EXPOSE 80
\ No newline at end of file
......@@ -9,7 +9,10 @@ pip install mkdocs-material==8.5.11
## Lint Dockerfile
```sh
docker run --rm -i hadolint/hadolint < Dockerfile
echo "##Dockerfile.api" >> docs/docker/docker.md && docker run --rm -i --env-file $PWD/hadolint.env hadolint/hadolint < Dockerfile.api | while read line; do echo ${line}" " >> docs/docker/docker.md; done
```
## ENVSUBST
......@@ -42,3 +45,18 @@ flake8 api wsgi.py | while read line; do echo ${line}$" " >> docs/lint.md; done
./report.sh
mkdocs build -d public
```
## Build venv job
```sh
build-python:
stage: test
script:
- python -m venv venv
- source venv/bin/activate
- pip install -r vapormap/app/requirements/production.txt
artifacts:
paths:
- venv
expire_in: 1 day
```
......@@ -12,3 +12,4 @@ nav:
- Bootstrap HTML: frontend/bootlint.md
- Javascript: frontend/jshint.md
- Style CSS: frontend/stylelint.md
- Tests Dockerfiles: docker/docker.md
\ 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