From 819b7e1f67a60f74cef639e5990a4b044349a107 Mon Sep 17 00:00:00 2001 From: Marc Dirsus Date: Thu, 4 Jul 2024 20:18:27 +0200 Subject: [PATCH] add update to dockerfile --- .trunk/trunk.yaml | 1 + Dockerfile | 18 +++++------------- README.Docker.md | 22 ---------------------- 3 files changed, 6 insertions(+), 35 deletions(-) delete mode 100644 README.Docker.md diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index 9c8d4a7..40be718 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -17,6 +17,7 @@ runtimes: # This is the section where you manage your linters. (https://docs.trunk.io/check/configuration) lint: enabled: + - taplo@0.8.1 - actionlint@1.7.1 - bandit@1.7.9 - black@24.4.2 diff --git a/Dockerfile b/Dockerfile index 733d65a..e23386d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,15 @@ FROM python:3.13.0b3 AS base -# Prevents Python from writing pyc files. -ENV PYTHONDONTWRITEBYTECODE=1 +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* -# Keeps Python from buffering stdout and stderr to avoid situations where -# the application crashes without emitting any logs due to buffering. +ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 WORKDIR /app -# Create a non-privileged user that the app will run under. -# See https://docs.docker.com/go/dockerfile-user-best-practices/ ARG UID=10001 RUN adduser \ --disabled-password \ @@ -21,20 +20,13 @@ RUN adduser \ --uid "${UID}" \ appuser -# Download dependencies as a separate step to take advantage of Docker's caching. -# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds. -# Leverage a bind mount to requirements.txt to avoid having to copy them into -# into this layer. RUN --mount=type=bind,source=requirements.txt,target=requirements.txt \ python -m pip install --no-cache-dir -r requirements.txt -# Switch to the non-privileged user to run the application. USER appuser -# Copy the source code into the container. COPY app.py . -# Expose the port that the application listens on. EXPOSE 8000 HEALTHCHECK --interval=10s --timeout=10s --start-period=5s --retries=3 CMD curl -f http://localhost:8000/health | grep OK || exit 1 diff --git a/README.Docker.md b/README.Docker.md deleted file mode 100644 index 6dae561..0000000 --- a/README.Docker.md +++ /dev/null @@ -1,22 +0,0 @@ -### Building and running your application - -When you're ready, start your application by running: -`docker compose up --build`. - -Your application will be available at http://localhost:8000. - -### Deploying your application to the cloud - -First, build your image, e.g.: `docker build -t myapp .`. -If your cloud uses a different CPU architecture than your development -machine (e.g., you are on a Mac M1 and your cloud provider is amd64), -you'll want to build the image for that platform, e.g.: -`docker build --platform=linux/amd64 -t myapp .`. - -Then, push it to your registry, e.g. `docker push myregistry.com/myapp`. - -Consult Docker's [getting started](https://docs.docker.com/go/get-started-sharing/) -docs for more detail on building and pushing. - -### References -* [Docker's Python guide](https://docs.docker.com/language/python/) \ No newline at end of file