From 7aee935686e9a1cb9a86a6af09426e3e625f527d Mon Sep 17 00:00:00 2001 From: Eunhak Lee <lee@enak.kr> Date: Tue, 3 Dec 2024 04:45:17 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20Gitlab=20CI=20=EB=A5=BC=20=ED=86=B5?= =?UTF-8?q?=ED=95=9C=20Docker=20image=20=EB=B0=B0=ED=8F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 16 ++++++++++++++++ .gitlab-ci.yml | 24 ++++++++++++++++++++++++ Dockerfile | 11 +++++++++++ 3 files changed, 51 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitlab-ci.yml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..1a2222e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,16 @@ +.DS_Store + +/venv/ +__pycache__ +*.pyc + +*.html +*.json +*.xml +*.zip + +*.txt +!/requirements.txt + +.env* +!/.env.example diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..019d55b --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,24 @@ +stages: + - deploy + +deploy: + image: docker + services: + - "docker:dind" + tags: + - dind + stage: deploy + only: + - main + - master + + before_script: + - echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin + + script: + - docker build --cache-from $CI_REGISTRY_IMAGE:latest -t $CI_REGISTRY_IMAGE:latest -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA . + - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA + - docker push $CI_REGISTRY_IMAGE:latest + + after_script: + - docker logout $CI_REGISTRY diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..926045b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM python:3.13-alpine + +WORKDIR /app +COPY ./requirements.txt /app + +RUN pip install -r requirements.txt + +COPY . /app + +ENTRYPOINT ["python"] +CMD ["push_to_db.py"] -- GitLab