Multistage build
This commit is contained in:
19
Dockerfile
19
Dockerfile
@ -1,12 +1,13 @@
|
|||||||
FROM python:3.10.11-alpine3.17
|
FROM python:3.10.11-alpine3.17 as env-builder
|
||||||
|
|
||||||
# handle optional arguments
|
# handle optional arguments
|
||||||
ARG INTERNAL_API_PORT=8010
|
ARG INTERNAL_API_PORT=8010
|
||||||
ARG INTERNAL_WS_PORT=8011
|
ARG INTERNAL_WS_PORT=8011
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
pip install pip -U && \
|
apk add --no-cache gcc musl-dev libffi-dev && \
|
||||||
pip install poetry --no-cache-dir
|
pip install pip -U --no-cache-dir --prefer-binary && \
|
||||||
|
pip install poetry --no-cache-dir --prefer-binary
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@ -29,6 +30,18 @@ RUN \
|
|||||||
# install python libs
|
# install python libs
|
||||||
pip install -r requirements.txt --no-cache-dir --prefer-binary
|
pip install -r requirements.txt --no-cache-dir --prefer-binary
|
||||||
|
|
||||||
|
|
||||||
|
FROM python:3.10.11-alpine3.17 as runner
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=env-builder /venv /venv
|
||||||
|
|
||||||
|
# set python thingies and activate virtual environment
|
||||||
|
ENV \
|
||||||
|
PYTHONDONTWRITEBYTECODE=1 \
|
||||||
|
PYTHONUNBUFFERED=1 \
|
||||||
|
PATH="/venv/bin:$PATH"
|
||||||
|
|
||||||
# copy all relevant files
|
# copy all relevant files
|
||||||
COPY ./.docker/* ./
|
COPY ./.docker/* ./
|
||||||
COPY ./hopper ./hopper
|
COPY ./hopper ./hopper
|
||||||
|
|||||||
5
Makefile
5
Makefile
@ -38,10 +38,11 @@ docker-clean:
|
|||||||
|
|
||||||
docker-build:
|
docker-build:
|
||||||
@docker \
|
@docker \
|
||||||
build . \
|
buildx build \
|
||||||
--build-arg INTERNAL_API_PORT=$(INTERNAL_API_PORT) \
|
--build-arg INTERNAL_API_PORT=$(INTERNAL_API_PORT) \
|
||||||
--build-arg INTERNAL_WS_PORT=$(INTERNAL_WS_PORT) \
|
--build-arg INTERNAL_WS_PORT=$(INTERNAL_WS_PORT) \
|
||||||
-t $(CONTAINER_NAME)
|
--tag $(CONTAINER_NAME) \
|
||||||
|
.
|
||||||
|
|
||||||
docker-run:
|
docker-run:
|
||||||
@docker \
|
@docker \
|
||||||
|
|||||||
Reference in New Issue
Block a user