Commit cdbb1861 authored by Marco Cavalli's avatar Marco Cavalli
Browse files

feat: add dockerfile and pipeline

parent 01839849
Loading
Loading
Loading
Loading
Loading

.gitlab-ci.yml

0 → 100644
+60 −0
Original line number Diff line number Diff line
stages:
  - build
  - test

variables:
  DOCKER_DRIVER: overlay2
  IMAGE_NAME: registry.gitlab.com/$CI_PROJECT_PATH/app
  DOCKER_TLS_CERTDIR: ""

build_image:
  stage: build
  image: docker:25.0.3
  services:
    - docker:25.0.3-dind
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      changes:
        - Dockerfile
        - requirements.txt

    - if: '$CI_COMMIT_BRANCH == "develop"'
      changes:
        - Dockerfile
        - requirements.txt
    - when: never

  script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY

    - docker pull $IMAGE_NAME:cache || true

    - docker build \
        --cache-from=$IMAGE_NAME:cache \
        -t $IMAGE_NAME:$CI_COMMIT_SHA \
        -t $IMAGE_NAME:cache \
        .

    - docker push $IMAGE_NAME:$CI_COMMIT_SHA
    - docker push $IMAGE_NAME:cache

  artifacts:
    expire_in: 1 week
    reports:
      dotenv: build.env
  after_script:
    - echo "IMAGE_TAG=$CI_COMMIT_SHA" >> build.env

test_documentation:
  stage: test
  image: $IMAGE_NAME:$CI_COMMIT_SHA
  needs: ["build_image"]
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
    - if: '$CI_COMMIT_BRANCH == "develop"'
    - when: never
  variables:
    GIT_STRATEGY: clone 
  script:
    - ls -la
    - python -m unittest discover -s ./doc/tests -t ./doc
 No newline at end of file

Dockerfile

0 → 100644
+8 −0
Original line number Diff line number Diff line
FROM python:3.12

WORKDIR /app
COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt

CMD ["python", "-m", "unittest", "discover", "-s", "./doc/tests", "-t", "./doc"]
 No newline at end of file