From 5b6090e88d05804c048c67f27356331a9ff4c29b Mon Sep 17 00:00:00 2001 From: BryantHe Date: Mon, 10 Jul 2023 12:54:22 +0800 Subject: [PATCH] update file --- .drone.yml | 34 +++++++++++++++++++++++++--------- Dockerfile | 6 ++++-- app.py | 4 ++++ docker-compose.yml | 4 ++-- requirements.txt | 1 + test.py | 1 - 6 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 app.py create mode 100644 requirements.txt delete mode 100644 test.py diff --git a/.drone.yml b/.drone.yml index d263622..2ea2c9a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -134,7 +134,7 @@ steps: kind: pipeline type: docker -name: main-merge-pull-request-prod +name: main-tag-prod platform: os: linux @@ -146,16 +146,32 @@ trigger: - main event: include: - - push + - tag clone: disable: true steps: - - name: semantic-release - image: lework/semantic-release - settings: - git_login: - from_secret: gitea_user - git_password: - from_secret: gitea_password \ No newline at end of file +- name: clone-repo + image: alpine/git + commands: + - git clone ${DRONE_GIT_HTTP_URL} . + - git checkout ${DRONE_BRANCH} +- name: build-and-push-image + image: plugins/docker + settings: + registry: + from_secret: Œ + username: + from_secret: docker_username + password: + from_secret: docker_password + repo: gitea.bearcatlog.com/bryant/todo + context: . + dockerfile: ./Dockerfile + tags: + - ${DRONE_TAG} + # auto_tag: true + purge: true + compress: true +# TODO 通知 k8s 更新镜像 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index f2187d0..6051935 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM python:3.11 -#WORKDIR /app +WORKDIR /app -# CMD ["python3", "test.py"] \ No newline at end of file +RUN python3 -m pip install -i https://mirrors.cloud.tencent.com/pypi/simple --trusted-host=mirrors.cloud.tencent.com -r requirements.txt + +CMD ["python3", "app.py"] \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..4b9f0a6 --- /dev/null +++ b/app.py @@ -0,0 +1,4 @@ +from apiflask import APIFlask + +app = APIFlask(__name__) +app.run() \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 6262d81..13680db 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,10 +12,10 @@ services: environment: TZ: "Asia/Shanghai" tty: true - working_dir: /app - command: ["python3", "test.py"] networks: - todo-service + ports: + - "5010:5000" networks: todo-service: diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..179576d --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +apiflask>=1.3.1 diff --git a/test.py b/test.py deleted file mode 100644 index 5b40bfb..0000000 --- a/test.py +++ /dev/null @@ -1 +0,0 @@ -print('hello drone') \ No newline at end of file