diff --git a/CHANGELOG b/CHANGELOG index 119a8097a3d3fc2956fc5000494c746e6a36df95..c6dde5d1fe7f39fc417474bb9b345f2b36b9f646 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.1] - 2024-06-13 + +### Added + +- Application PORT is now configurable. + ## [1.0.0] - 2024-04-18 ### Added diff --git a/copier.yml b/copier.yml index f4c0d3c94394930830c2bcdd9de4c81e8a232c0d..7f1b3fcb8670572faa25c1c05d995c9f95d88396 100644 --- a/copier.yml +++ b/copier.yml @@ -36,6 +36,11 @@ python_version: help: "Python version to be used." default: "3.11" +app_port: + type: int + help: "Default port for the application." + default: 8080 + include_tests: type: bool help: "Include test setup or not." diff --git a/template/Dockerfile b/template/Dockerfile index 7df30d981a2a7552c719174473c880a4ef24b71f..9a0a3eb32ae6f15ed70b5c1c4ea6f2531291f7a4 100644 --- a/template/Dockerfile +++ b/template/Dockerfile @@ -10,6 +10,9 @@ FROM registry.gitlab.developers.cam.ac.uk/uis/devops/infra/dockerimages/python:3 ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 +# Set the PORT env variable with a default value +ENV PORT={{ app_port }} + WORKDIR /usr/src/app # Pretty much everything from here on needs poetry. @@ -42,7 +45,7 @@ FROM install_deps AS development RUN poetry install --only=dev --no-root -CMD ["uvicorn", "{{ project_slug }}.main:app", "--reload", "--host", "0.0.0.0", "--port", "8000"] +CMD exec uvicorn {{ project_slug }}.main:app --reload --host 0.0.0.0 --port $PORT ############################################################################### # The last target in the file is the "default" one. In our case it is the @@ -54,4 +57,4 @@ FROM install_deps as production # The production target includes the application code. COPY . . -CMD ["uvicorn", "{{ project_slug }}.main:app", "--host", "0.0.0.0", "--port", "8000"] +CMD exec uvicorn {{ project_slug }}.main:app --host 0.0.0.0 --port $PORT diff --git a/template/docker-compose.yml b/template/docker-compose.yml index ba2728d711bcaac71f350e38773beab12b3a431c..cd3f24cccb3d4439a8975bc2fb2d1d006ee28f83 100644 --- a/template/docker-compose.yml +++ b/template/docker-compose.yml @@ -6,7 +6,7 @@ services: context: . target: development ports: - - "8000:8000" + - "{{ app_port }}:{{ app_port }}" profiles: - development volumes: @@ -17,7 +17,7 @@ services: context: . target: production ports: - - "8000:8000" + - "{{ app_port }}:{{ app_port }}" profiles: - production volumes: