Spaces:
Sleeping
Sleeping
Commit
·
c9569d3
1
Parent(s):
56f8c1c
added dockerfile
Browse files- .dockerignore +34 -0
- Dockerfile +54 -0
.dockerignore
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Include any files or directories that you don't want to be copied to your
|
| 2 |
+
# container here (e.g., local build artifacts, temporary files, etc.).
|
| 3 |
+
#
|
| 4 |
+
# For more help, visit the .dockerignore file reference guide at
|
| 5 |
+
# https://docs.docker.com/go/build-context-dockerignore/
|
| 6 |
+
|
| 7 |
+
**/.DS_Store
|
| 8 |
+
**/__pycache__
|
| 9 |
+
**/.venv
|
| 10 |
+
**/.classpath
|
| 11 |
+
**/.dockerignore
|
| 12 |
+
**/.env
|
| 13 |
+
**/.git
|
| 14 |
+
**/.gitignore
|
| 15 |
+
**/.project
|
| 16 |
+
**/.settings
|
| 17 |
+
**/.toolstarget
|
| 18 |
+
**/.vs
|
| 19 |
+
**/.vscode
|
| 20 |
+
**/*.*proj.user
|
| 21 |
+
**/*.dbmdl
|
| 22 |
+
**/*.jfm
|
| 23 |
+
**/bin
|
| 24 |
+
**/charts
|
| 25 |
+
**/docker-compose*
|
| 26 |
+
**/compose.y*ml
|
| 27 |
+
**/Dockerfile*
|
| 28 |
+
**/node_modules
|
| 29 |
+
**/npm-debug.log
|
| 30 |
+
**/obj
|
| 31 |
+
**/secrets.dev.yaml
|
| 32 |
+
**/values.dev.yaml
|
| 33 |
+
LICENSE
|
| 34 |
+
README.md
|
Dockerfile
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## the base or builder stage commands
|
| 2 |
+
|
| 3 |
+
# decide on the python version
|
| 4 |
+
FROM python:3.13.3-slim-bookworm AS base
|
| 5 |
+
|
| 6 |
+
# get the build essential tools
|
| 7 |
+
RUN apt-get update && apt-get install --no-install-recommends -y \
|
| 8 |
+
curl ca-certificates && \
|
| 9 |
+
apt-get clean && rm -rf /var/lib/apt/lists/* ~/.cache/
|
| 10 |
+
|
| 11 |
+
# download the latest version of uv
|
| 12 |
+
ADD https://astral.sh/uv/0.7.3/install.sh /install.sh
|
| 13 |
+
RUN chmod -R 655 /install.sh && /install.sh && rm /install.sh
|
| 14 |
+
|
| 15 |
+
# add uv to path
|
| 16 |
+
ENV PATH="/root/.local/bin:${PATH}"
|
| 17 |
+
|
| 18 |
+
# define work directory
|
| 19 |
+
WORKDIR /app
|
| 20 |
+
|
| 21 |
+
# copy the env setup file only
|
| 22 |
+
COPY pyproject.toml ./pyproject.toml
|
| 23 |
+
|
| 24 |
+
RUN uv sync --no-cache-dir --compile-bytecode \
|
| 25 |
+
--no-install-project --verbose
|
| 26 |
+
|
| 27 |
+
# ------------------------------------------------------- #
|
| 28 |
+
|
| 29 |
+
## the main or production stage commands
|
| 30 |
+
|
| 31 |
+
# same python version as base / builder stage
|
| 32 |
+
FROM python:3.13.3-slim-bookworm AS main
|
| 33 |
+
|
| 34 |
+
# create a non-root user
|
| 35 |
+
RUN useradd --create-home app_user
|
| 36 |
+
USER app_user
|
| 37 |
+
|
| 38 |
+
# define work directory
|
| 39 |
+
WORKDIR /app
|
| 40 |
+
|
| 41 |
+
# copy env files from base to main image
|
| 42 |
+
COPY --from=base /app/.venv ./.venv
|
| 43 |
+
|
| 44 |
+
# add app env var to path
|
| 45 |
+
ENV PATH="/app/.venv/bin:$PATH"
|
| 46 |
+
|
| 47 |
+
# copy project folders and files into image
|
| 48 |
+
COPY main.py ./main.py
|
| 49 |
+
|
| 50 |
+
# expose the port
|
| 51 |
+
EXPOSE 7860
|
| 52 |
+
|
| 53 |
+
# start the application
|
| 54 |
+
CMD ["uvicorn", "main:app", "--log-level", "info", "--host", "0.0.0.0" , "--port", "7860", "--workers", "1"]
|