Skip to content

Commit

Permalink
[DH-5575] Add env var to change the container port (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcjc712 authored and DishenWang2023 committed May 7, 2024
1 parent 396eb5f commit 49b0504
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ MONGODB_DB_PASSWORD = 'admin'
S3_AWS_ACCESS_KEY_ID=
S3_AWS_SECRET_ACCESS_KEY=
ONLY_STORE_CSV_FILES_LOCALLY = False # Set to True if only want to save generated CSV files locally instead of S3. Note that if stored locally they should be treated as ephemeral, i.e., they will disappear when the engine is restarted.

CORE_PORT = 80 # This env var defines the port that will be exposed by the container. It serves as the configuration for both the internal and external container ports.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt

COPY . /app

EXPOSE 80
# Set default CORE_PORT to 80 if not provided
ARG CORE_PORT=80
ENV CORE_PORT=${CORE_PORT}

CMD ["uvicorn", "dataherald.app:app", "--host", "0.0.0.0", "--port", "80"]
EXPOSE ${CORE_PORT}

CMD ["uvicorn", "dataherald.app:app", "--host", "0.0.0.0", "--port", "${CORE_PORT}"]
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ services:
context: .
dockerfile: Dockerfile
ports:
- "80:80"
command: uvicorn dataherald.app:app --host 0.0.0.0 --port 80 --log-config log_config.yml --log-level debug --reload
- "${CORE_PORT:-80}:${CORE_PORT:-80}"
environment:
- CORE_PORT=${CORE_PORT:-80}
command: uvicorn dataherald.app:app --host 0.0.0.0 --port ${CORE_PORT:-80} --log-config log_config.yml --log-level debug --reload
stdin_open: true
tty: true
volumes:
Expand Down

0 comments on commit 49b0504

Please sign in to comment.