diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..283963cd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.idea +.devcontainer +.git +.gitignore +.github +.vscode diff --git a/.gitignore b/.gitignore index bb862c87..6c05dd93 100644 --- a/.gitignore +++ b/.gitignore @@ -157,7 +157,7 @@ cython_debug/ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ +.idea/ # custom env.sh diff --git a/Dockerfile b/Dockerfile index fcdafb68..94fd1ed3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,34 @@ -FROM python:3.11-slim +## Build dependencies +FROM python:3.11-slim as dependencies + +WORKDIR /usr/src/app + +RUN apt-get update && \ + apt-get install -y --no-install-recommends gcc \ + && rm -rf /var/lib/apt/lists/* + +RUN python -m venv /opt/venv +ENV PATH="/opt/venv/bin:$PATH" -ARG GITHUB_TOKEN -ENV GITHUB_TOKEN $GITHUB_TOKEN +COPY requirements.txt . + +RUN pip install -r requirements.txt + +## Image +FROM python:3.11-slim WORKDIR /usr/src/app +RUN apt-get update && \ + apt-get install -y --no-install-recommends curl \ + && rm -rf /var/lib/apt/lists/* + +ENV PATH="/opt/venv/bin:$PATH" + +COPY --from=dependencies /opt/venv /opt/venv COPY . . -RUN apt update && \ - apt-get install build-essential libffi-dev libssl-dev openssl --no-install-recommends -y \ - && pip install --no-cache-dir -r requirements.txt +CMD docker/run-backend.sh +HEALTHCHECK CMD docker/run-healthcheck.sh -CMD [ "python3", "-m" , "sanic", "app:app", "--fast", "--access-logs", "--motd", "--noisy-exceptions", "-H", "0.0.0.0"] +EXPOSE 8000 diff --git a/docker/run-backend.sh b/docker/run-backend.sh new file mode 100755 index 00000000..1e7b51ac --- /dev/null +++ b/docker/run-backend.sh @@ -0,0 +1 @@ +python3 -m sanic /usr/src/app --fast --access-logs --motd --noisy-exceptions -H 0.0.0.0 diff --git a/docker/run-healthcheck.sh b/docker/run-healthcheck.sh new file mode 100755 index 00000000..1c514a54 --- /dev/null +++ b/docker/run-healthcheck.sh @@ -0,0 +1 @@ +curl --fail http://0.0.0.0:8000/docs