FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 297ed86e authored by E. Evstafiev's avatar E. Evstafiev :bulb:
Browse files

Merge branch 'add-default-port-configuration' into 'main'

feat: Add application port configuration

See merge request !5
parents b271111d 68f32acc
No related branches found
No related tags found
1 merge request!5feat: Add application port configuration
Pipeline #545724 passed
......@@ -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
......
......@@ -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."
......
......@@ -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
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment