diff --git a/Dockerfile b/Dockerfile index fd27fd8..3a88d65 100644 --- a/Dockerfile +++ b/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 ARG INTERNAL_API_PORT=8010 ARG INTERNAL_WS_PORT=8011 RUN \ - pip install pip -U && \ - pip install poetry --no-cache-dir + apk add --no-cache gcc musl-dev libffi-dev && \ + pip install pip -U --no-cache-dir --prefer-binary && \ + pip install poetry --no-cache-dir --prefer-binary WORKDIR /app @@ -29,6 +30,18 @@ RUN \ # install python libs 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 ./.docker/* ./ COPY ./hopper ./hopper diff --git a/Makefile b/Makefile index 7b2fd0d..8ac702b 100644 --- a/Makefile +++ b/Makefile @@ -38,10 +38,11 @@ docker-clean: docker-build: @docker \ - build . \ + buildx build \ --build-arg INTERNAL_API_PORT=$(INTERNAL_API_PORT) \ --build-arg INTERNAL_WS_PORT=$(INTERNAL_WS_PORT) \ - -t $(CONTAINER_NAME) + --tag $(CONTAINER_NAME) \ + . docker-run: @docker \