diff --git a/Dockerfile b/Dockerfile index 6d68dcf..82932d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,11 +7,14 @@ RUN npm install RUN echo "VITE_APIURL=/api/v1" > .env.production RUN npm run build -FROM python:3.11-alpine as runner +FROM python:3.11-alpine as python-builder -LABEL org.opencontainers.image.source=https://github.com/Donkie/Spoolman -LABEL org.opencontainers.image.description="Keep track of your inventory of 3D-printer filament spools." -LABEL org.opencontainers.image.licenses=MIT +RUN apk update \ + && apk add \ + build-base \ + python3-dev \ + gcc \ + libc-dev # Add local user so we don't run as root RUN adduser -D app @@ -32,9 +35,28 @@ COPY --chown=app:app README.md /home/app/spoolman/ WORKDIR /home/app/spoolman RUN pip install -e . +FROM python:3.11-alpine as python-runner + +LABEL org.opencontainers.image.source=https://github.com/Donkie/Spoolman +LABEL org.opencontainers.image.description="Keep track of your inventory of 3D-printer filament spools." +LABEL org.opencontainers.image.licenses=MIT + +# Add local user so we don't run as root +RUN adduser -D app +USER app + # Copy built client COPY --chown=app:app --from=client-builder /client/dist /home/app/spoolman/client/dist +# Copy built app +COPY --chown=app:app --from=python-builder /home/app/.local /home/app/.local +COPY --chown=app:app --from=python-builder /home/app/spoolman /home/app/spoolman + +WORKDIR /home/app/spoolman + +ENV PATH="/home/app/.local/bin:${PATH}" +ENV PYTHONPATH="/home/app/spoolman:${PYTHONPATH}" + # Run command EXPOSE 8000 ENTRYPOINT ["uvicorn", "spoolman.main:app"] diff --git a/requirements.txt b/requirements.txt index 1af54ef..63e0cae 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,8 @@ -uvicorn[standard]==0.21.1 +# Uvicorn and some of its optional dependencies +uvicorn==0.22.0 +httptools>=0.5.0; platform_machine != 'armv7l' +uvloop>=0.14.0,!=0.15.0,!=0.15.1; platform_machine != 'armv7l' and sys_platform != 'win32' and (sys_platform != 'cygwin' and platform_python_implementation != 'PyPy') + fastapi==0.95.0 SQLAlchemy[asyncio,aiomysql,postgresql_asyncpg,aiosqlite]==2.0.15 pydantic==1.10.7