Commit 7515ef62 authored by Benavides Ontiveros's avatar Benavides Ontiveros
Browse files

odify .\.gitlab-ci.yml

parent 1d94f7d7
Pipeline #12158 failed
...@@ -8,10 +8,12 @@ stages: ...@@ -8,10 +8,12 @@ stages:
variables: variables:
PYTHONPATH: "${CI_PROJECT_DIR}" PYTHONPATH: "${CI_PROJECT_DIR}"
DOCKER_REGISTRY: "docker.io" DOCKER_REGISTRY: "docker.io"
DOCKERHUB_REPO: "$DOCKER_USERNAME/reddit_data_fetcher" # Replace with your repo DOCKERHUB_REPO: "$DOCKER_USERNAME/reddit_data_fetcher"
# ----------------- Base Template -----------------
.build_template: .build_template:
tags: ["ubuntu", "vm"] # Match your runner tags tags: ["ubuntu", "vm"]
image: docker:24.0.9
before_script: before_script:
- echo "Docker CLI info:" - echo "Docker CLI info:"
- docker version - docker version
...@@ -22,6 +24,8 @@ lint: ...@@ -22,6 +24,8 @@ lint:
image: python:3.10 image: python:3.10
extends: .build_template extends: .build_template
before_script: before_script:
- echo "Docker CLI info:"
- docker version
- pip install flake8 - pip install flake8
script: script:
- echo "Linting Python code..." - echo "Linting Python code..."
...@@ -40,6 +44,8 @@ test: ...@@ -40,6 +44,8 @@ test:
image: python:3.10 image: python:3.10
extends: .build_template extends: .build_template
before_script: before_script:
- echo "Docker CLI info:"
- docker version
- pip install pytest - pip install pytest
- echo "Running Tests" - echo "Running Tests"
- echo "PYTHONPATH: ${PYTHONPATH}" - echo "PYTHONPATH: ${PYTHONPATH}"
...@@ -57,8 +63,7 @@ test: ...@@ -57,8 +63,7 @@ test:
# ----------------- Diagnostics Stage ----------------- # ----------------- Diagnostics Stage -----------------
diag: diag:
stage: diag stage: diag
image: docker:24.0.9 extends: .build_template
tags: ["ubuntu","vm"]
script: script:
- echo "Check Docker socket and info..." - echo "Check Docker socket and info..."
- ls -l /var/run || true - ls -l /var/run || true
...@@ -74,7 +79,6 @@ diag: ...@@ -74,7 +79,6 @@ diag:
# ----------------- Build Stage ----------------- # ----------------- Build Stage -----------------
build: build:
stage: build stage: build
image: docker:24.0.9
extends: .build_template extends: .build_template
before_script: before_script:
- echo "Logging in to Docker registry..." - echo "Logging in to Docker registry..."
...@@ -97,8 +101,7 @@ build: ...@@ -97,8 +101,7 @@ build:
# ----------------- Deploy Stage ----------------- # ----------------- Deploy Stage -----------------
deploy: deploy:
stage: deploy stage: deploy
image: docker:24.0.9 extends: .build_template
tags: ["ubuntu","vm"]
script: script:
- echo "Logging in to Docker registry..." - echo "Logging in to Docker registry..."
- echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin - echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin
...@@ -111,14 +114,13 @@ deploy: ...@@ -111,14 +114,13 @@ deploy:
docker push $DOCKERHUB_REPO:latest; docker push $DOCKERHUB_REPO:latest;
fi fi
# Optional: Run container to test runtime env variables # Optional: Run container to test runtime environment variables
- docker run --rm \ - docker run --rm \
-e SUBREDDITS="$SUBREDDITS" \ -e SUBREDDITS="$SUBREDDITS" \
-e POST_LIMIT="$POST_LIMIT" \ -e POST_LIMIT="$POST_LIMIT" \
-e COMMENT_LIMIT="$COMMENT_LIMIT" \ -e COMMENT_LIMIT="$COMMENT_LIMIT" \
-e OUTPUT_DIR="$OUTPUT_DIR" \ -e OUTPUT_DIR="$OUTPUT_DIR" \
$DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA
rules: rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never when: never
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment