From f642f9fb6c95d752c3fb6ac16e96eea4ada317ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20=C5=A0trauch?= Date: Sat, 25 Oct 2025 01:36:17 +0200 Subject: [PATCH] Dockerfile --- .gitignore | 1 + Dockerfile | 18 ++++++++++++++++++ Taskfile.yml | 19 +++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 Dockerfile diff --git a/.gitignore b/.gitignore index 6815585..ca8e4a1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ venv/ cache*.json Rostifile __pycache__/ +.vscode/*.log diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f0ad460 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3.12-alpine + +WORKDIR /app + +# Copy the source files +COPY ./calculator /app/calculator +COPY ./requirements.txt /app/requirements.txt + +# Install dependencies into a virtual environment +RUN python -m venv /app/venv && \ + /app/venv/bin/pip install --no-cache-dir --upgrade -r /app/requirements.txt + +# Mark data storage and expose port +VOLUME /app/cache +EXPOSE 8000 + +ENTRYPOINT ["/app/venv/bin/fastapi"] +CMD ["run", "calculator/main.py"] diff --git a/Taskfile.yml b/Taskfile.yml index 2ceafd3..a2d7aae 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -2,10 +2,17 @@ version: '3' +vars: + IMAGE: gitea.ceperka.net/cx/pricepower + TAG: dev + tasks: dev : cmds: - fastapi dev calculator/main.py --reload + + # Old app deployment + deploy: cmds: - ssh -p 11335 app@ssh.rosti.cz mkdir -p /srv/app/cache @@ -13,3 +20,15 @@ tasks: - rsync -av -e "ssh -p 11335" ./requirements.txt app@ssh.rosti.cz:/srv/app/ - ssh -p 11335 app@ssh.rosti.cz /srv/venv/bin/pip install -r /srv/app/requirements.txt - ssh -p 11335 app@ssh.rosti.cz supervisorctl restart app + + # New deployment + + build: + cmds: + - docker build -t {{ .IMAGE }}:{{ .TAG }} . + tag-latest: + cmds: + - docker tag {{ .IMAGE }}:{{ .TAG }} {{ .IMAGE }}:latest + push: + cmds: + - docker push {{ .IMAGE }}:{{ .TAG }}