From f482ed80dbfa25f4b222a96b5ebf5e975c385e7d Mon Sep 17 00:00:00 2001 From: Marciel Torres Date: Sun, 26 Nov 2023 11:14:51 -0300 Subject: [PATCH] Adding docker build and push commands (#40) --- Dockerfile | 3 ++- Makefile | 15 +++++++++++++-- README.md | 2 ++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index d332f30..f724787 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,4 +14,5 @@ COPY . . FROM dependencies AS production COPY src src -COPY settings.toml src +COPY settings.conf src +COPY logging.conf src diff --git a/Makefile b/Makefile index 8a3daac..1fb3d0f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ APP_NAME="python-boilerplate-project" +IMAGE_NAME="python-boilerplate-project" +VERSION="latest" ################################ # COMMANDS TO RUN LOCALLY @@ -19,7 +21,6 @@ local/lint/fix: local/run: poetry run python src/main.py - ############################################ # COMMANDS TO RUN USING DOCKER (RECOMMENDED) ############################################ @@ -45,9 +46,19 @@ docker/lint/fix: docker/run: docker-compose run ${APP_NAME} poetry run python src/main.py +#################################### +# DOCKER IMAGE COMMANDS +#################################### + +docker/image/build: + docker build . --target production -t ${IMAGE_NAME}:${VERSION} + +docker/image/push: + docker push ${IMAGE_NAME}:${VERSION} + ################## # HEPFUL COMMANDS ################## generate-default-env-file: - @if [ ! -f .env ]; then cp env.template .env; fi; \ No newline at end of file + @if [ ! -f .env ]; then cp env.template .env; fi; diff --git a/README.md b/README.md index 5f05211..742896a 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,8 @@ tests | `make docker/tests` | `make local/tests` | to run the tests with coverag lint | `make docker/lint` | `make local/lint` | to run static code analysis using ruff lint/fix | `make docker/lint/fix` | `make local/lint/fix` | to fix files using ruff run | `make docker/run` | `make local/run` | to run the project +build image | `make docker/image/build` | - | to build the docker image +push image | `make docker/image/push` | - | to push the docker image **Helpful commands**