Skip to content

Commit

Permalink
fixes and enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
John Dutchover committed Feb 10, 2024
1 parent e433aaf commit 7414fbb
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ deploy-backend:
script:
- echo "Deploy backend app from $CI_COMMIT_BRANCH branch"
- flyctl auth token $FLY_API_TOKEN
- flyctl deploy --ha=false --config app/fly.production.toml
- flyctl deploy --ha=false --config app/fly.toml
environment: production
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"'
Expand Down
10 changes: 7 additions & 3 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Use an official Python runtime as a parent image
FROM python:3.11.6
FROM python:3.11.7

# Set the working directory in the container image
# Set the working directory in the Docker image
WORKDIR /usr/src

# Copy the requirements.txt first to leverage container cache
# Copy the requirements.txt first to leverage Docker cache
COPY app/requirements.txt ./app/
RUN pip install --no-cache-dir -r app/requirements.txt

Expand All @@ -14,6 +14,10 @@ COPY app/ ./app/
# Make port 8000 available to the world outside this container
EXPOSE 8000

HEALTHCHECK --interval=5m --timeout=3s \
--start-period=1m \
CMD curl --fail http://localhost:8000/docs || exit 1

# Run app.main when the container launches
CMD ["python", "-m", "app.main"]
# For k8s
Expand Down
3 changes: 3 additions & 0 deletions app/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@
**/**/.ssh/id_*
**/**/.ssh/*_id_*

# Makefile
Makefile

# End of file
9 changes: 6 additions & 3 deletions app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ FROM python:3.11.7
# Set the working directory in the Docker image
WORKDIR /usr/src/app

# Create the requirements directory
RUN mkdir requirements

# Copy the requirements.txt first to leverage Docker cache
COPY app/requirements/requirements.txt /usr/src/app/requirements/
COPY requirements/requirements.txt /usr/src/app/requirements/
RUN pip install --no-cache-dir -r requirements/requirements.txt

# Copy the app directory contents into the container at /usr/src/app
COPY app/ /usr/src/app/
COPY . /usr/src/app/

# Make port 8000 available to the world outside this container
EXPOSE 8000
Expand All @@ -22,6 +25,6 @@ HEALTHCHECK --interval=5m --timeout=3s \
CMD curl --fail http://localhost:8000/docs || exit 1

# Run main.py when the container launches
CMD ["python", "main.py", "--host", "127.0.0.1", "--port", "8000"]
CMD ["python", "main.py", "--host", "0.0.0.0", "--port", "8000"]

ENV APP_MODULE=main
5 changes: 5 additions & 0 deletions app/fly.production.toml → app/fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ dockerfile = "Dockerfile"
internal_port = 8000
processes = ["app"]

[[services.ports]]
handlers = ["http"]
port = 8000
force_https = true

[http_service]
internal_port = 8000
force_https = true
Expand Down
2 changes: 1 addition & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ class Person(BaseModel):
if __name__ == "__main__":
import uvicorn

uvicorn.run(app, host="127.0.0.1", port=8000)
uvicorn.run(app, host="0.0.0.0", port=8000)
2 changes: 1 addition & 1 deletion app/requirements/requirements-dev.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# requirements-dev.in
-r requirements.in
-r requirements.txt
conventional-pre-commit
httpx
pre-commit
Expand Down
2 changes: 1 addition & 1 deletion app/requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ tzdata==2023.4
# via marvin
urllib3==2.2.0
# via requests
uvicorn==0.27.0.post1
uvicorn==0.27.1
# via marvin
zipp==3.17.0
# via importlib-metadata
2 changes: 1 addition & 1 deletion app/requirements/requirements-test.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# requirements-test.in
-r base.in
-r base.txt
black
flake8
mock
Expand Down
2 changes: 1 addition & 1 deletion app/requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ tzdata==2023.4
# via marvin
urllib3==2.2.0
# via requests
uvicorn==0.27.0.post1
uvicorn==0.27.1
# via marvin
zipp==3.17.0
# via importlib-metadata

0 comments on commit 7414fbb

Please sign in to comment.