FastAPI hello world with docker container.
This commit is contained in:
25
api_server/docker/Dockerfile
Normal file
25
api_server/docker/Dockerfile
Normal file
@@ -0,0 +1,25 @@
|
||||
FROM alpine:3.20 AS builder
|
||||
|
||||
RUN apk add --no-cache python3 poetry py3-poetry-plugin-export
|
||||
|
||||
RUN mkdir /source
|
||||
WORKDIR /source
|
||||
COPY pyproject.toml poetry.lock ./
|
||||
|
||||
RUN poetry export --output=requirements.txt
|
||||
|
||||
|
||||
|
||||
FROM alpine:3.20 AS runner
|
||||
|
||||
RUN addgroup web && adduser -D -G web web && install -d -D -o web -g web -m 700 /source
|
||||
WORKDIR /source
|
||||
RUN apk add --no-cache python3 py3-pip uvicorn
|
||||
|
||||
COPY --from=builder /source/requirements.txt /tmp
|
||||
RUN pip install --break-system-packages --no-cache-dir --upgrade -r /tmp/requirements.txt && rm /tmp/requirements.txt
|
||||
|
||||
USER web
|
||||
COPY --chown=web:web . .
|
||||
|
||||
ENTRYPOINT ["python", "-m", "uvicorn", "api_server.main:app", "--host", "0.0.0.0", "--port", "8080"]
|
||||
Reference in New Issue
Block a user