diff --git a/Makefile b/Makefile index f5656d4..9bce708 100644 --- a/Makefile +++ b/Makefile @@ -14,14 +14,24 @@ check: docker: python3 -m dotenv -f version_code run \ - docker build -t ${REPO_OWNER_LOWER}/${REPO_NAME_SNAKE}:$$VERSION . + make cmd-docker-build + +docker-build: + python3 -m dotenv -f version_code run \ + make cmd-docker-build docker-push: python3 -m dotenv -f version_code run \ - docker push ${REPO_OWNER_LOWER}/${REPO_NAME_SNAKE}:$$VERSION + make cmd-docker-push clean: rm -rf app/__pycache__ rm -rf app/*/__pycache__ rm -rf __pycache__ rm -rf .mypy_cache + +cmd-docker-build: + docker build -t ${REPO_OWNER_LOWER}/${REPO_NAME_SNAKE}:$${VERSION} . + +cmd-docker-push: + docker push ${REPO_OWNER_LOWER}/${REPO_NAME_SNAKE}:$$VERSION diff --git a/README.md b/README.md index 4304ff3..d8c8e1b 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,8 @@ Make commands: |`make check`|Check the code with linters (MyPy, Pylint)| |`make dev`|Run the app in development mode| |`make prod`|Run a production server| -|`make docker`|Build a docker image from `Dockerfile`| +|`make docker` or `make docker-build`|Build a docker image from `Dockerfile`| +|`make docker-push`|Upload the built image to Docker Hub| |`make clean`|Clean all cache| @@ -177,8 +178,8 @@ or call `with_redirect_307` function. to the Response contructor. **Args:** - url (str, optional): Target URL, root by default - code (int, optional): HTTP response code + - url (str, optional): Target URL, root by default + - code (int, optional): HTTP response code **Returns:** FastAPI's RedirectResponse object @@ -198,8 +199,8 @@ Return a plain text to the user. to the Response contructor. **Args:** - content (str): Plain text content - code (int, optional): HTTP response code + - content (str): Plain text content + - code (int, optional): HTTP response code **Returns:** FastAPI's PlainTextResponse object @@ -225,12 +226,12 @@ to your function if you specify the correct type hint (`: Request`) **Args:** - name (str): Template filename - request (Request): FastAPI request object - code (int, optional): HTTP response code - headers (Optional[Mapping[str, str]], optional): + - name (str): Template filename + - request (Request): FastAPI request object + - code (int, optional): HTTP response code + - headers (Optional[Mapping[str, str]], optional): Additional headers, passed to the Response constructor - background (Optional[BackgroundTask], optional): + - background (Optional[BackgroundTask], optional): Background task, passed to the Response constructor **Returns:** FastAPI's TemplateResponse object @@ -242,9 +243,9 @@ automatically guessing its mimetype if `mime` is None. to the Response contructor. **Args:** - path (os.PathLike): File path - mime (Optional[str], optional): File mimetype - code (int, optional): HTTP response code + - path (os.PathLike): File path + - mime (Optional[str], optional): File mimetype + - code (int, optional): HTTP response code **Returns:** FileResponse: FastAPI's FileResponse object @@ -259,8 +260,8 @@ See `respond.with_tmpl` for explanation about the `request` argument. **Args:** - form (Type[StarletteForm]): StarletteForm class - req (Request): Request object + - form (Type[StarletteForm]): StarletteForm class + - req (Request): Request object **Returns:** StarletteForm instance @@ -275,7 +276,7 @@ Code is copied from the official docs. ## Publishing app First of all, check the `version_code` file and correct it if needed, -Then build a Docker image using `make docker` command. +then build a Docker image using `make docker` command. Follow [this documentation page](https://docs.docker.com/get-started/04_sharing_app/) to create an account in the Docker Hub. diff --git a/docker-compose.yml b/docker-compose.yml index c76f131..ed99f8a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: "3" services: ${REPO_NAME_SNAKE}: - image: ${REPO_OWNER}/${REPO_NAME_SNAKE}:latest + image: ${REPO_OWNER_LOWER}/${REPO_NAME_SNAKE}:latest container_name: ${REPO_NAME_SNAKE} restart: unless-stopped ports: