diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 924fb24..945b979 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,26 +3,24 @@ workflow: variables: PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" + DOCKER_TLS_CERTDIR: "/certs" -cache: - paths: - - .cache/pip - - .cache/pip3 - - venv/ +services: + - docker:dind stages: - build - coverage_report - relatorio -# Stage to build the Docker image +# Stage to build the Docker image and push it to the registry build: stage: build + image: docker:stable script: - - docker build -t chrome-with-selenium:latest . - artifacts: - paths: - - chrome-with-selenium.tar + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + - docker build -t registry.gitlab.com/guilhermecgs/ir:latest . + - docker push registry.gitlab.com/guilhermecgs/ir:latest when: always before_script: @@ -31,7 +29,7 @@ before_script: coverage_html: stage: coverage_report - image: chrome-with-selenium:latest + image: registry.gitlab.com/guilhermecgs/ir:latest script: - python3 coverage_test.py - mkdir -p public/coverage_report @@ -46,7 +44,7 @@ coverage_html: relatorio: stage: relatorio - image: chrome-with-selenium:latest + image: registry.gitlab.com/guilhermecgs/ir:latest script: - python3 ./ir.py --do check_environment_variables # - python3 ./ir.py --do busca_trades_e_faz_merge_operacoes diff --git a/Dockerfile b/Dockerfile index c59328e..45d8346 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,10 @@ FROM python:3.10 +# Install system dependencies +RUN apt-get update && \ + apt-get install -y wget unzip && \ + apt-get clean + # install google chrome RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' @@ -17,8 +22,12 @@ ENV DISPLAY=:99 # upgrade pip RUN pip3 install --upgrade pip +# Set working directory WORKDIR /code + +# Copy requirements and install COPY ./requirements.txt /code/requirements.txt +RUN pip3 install --no-cache-dir --upgrade -r /code/requirements.txt -# install selenium -RUN pip3 install --no-cache-dir --upgrade -r /code/requirements.txt \ No newline at end of file +# Copy the rest of the application code +COPY . /code \ No newline at end of file