Skip to content

Commit

Permalink
feat: build slim first then recommended plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
johnson2427 committed Aug 13, 2024
1 parent 4522e99 commit 4d29c3a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 38 deletions.
42 changes: 4 additions & 38 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,9 @@
# See LICENSE in the project root for license information.
#---------------------------------------------------------------------------------------------

ARG PYTHON_VERSION="3.11"
ARG PLUGINS_FILE="./recommended-plugins.txt"
FROM ape:latest-slim

FROM python:${PYTHON_VERSION} as builder
RUN pip install --upgrade pip
RUN pip install /wheels/*.whl

WORKDIR /wheels

COPY ./recommended-plugins.txt ./recommended-plugins.txt
COPY . .

RUN pip install --upgrade pip \
&& pip install wheel \
&& pip wheel .[recommended-plugins] --wheel-dir=/wheels

FROM python:${PYTHON_VERSION}-slim

# See http://label-schema.org for metadata schema
# TODO: Add `build-date` and `version`
LABEL maintainer="ApeWorX" \
org.label-schema.schema-version="2.0" \
org.label-schema.name="ape" \
org.label-schema.description="Ape Ethereum Framework." \
org.label-schema.url="https://docs.apeworx.io/ape/stable/" \
org.label-schema.usage="https://docs.apeworx.io/ape/stable/userguides/quickstart.html#via-docker" \
org.label-schema.vcs-url="https://github.com/ApeWorX/ape" \
org.label-schema.docker.cmd="docker run --volume $HOME/.ape:/home/harambe/.ape --volume $HOME/.vvm:/home/harambe/.vvm --volume $HOME/.solcx:/home/harambe/.solcx --volume $PWD:/home/harambe/project --workdir /home/harambe/project apeworx/ape compile"

RUN useradd --create-home --shell /bin/bash harambe

COPY --from=builder /wheels /wheels
COPY ./recommended-plugins.txt ./recommended-plugins.txt

RUN pip install --upgrade pip \
pip install --no-cache-dir --find-links=/wheels -r ./recommended-plugins.txt \
&& ape --version

WORKDIR /home/harambe/project
RUN chown --recursive harambe:harambe /home/harambe
USER harambe
ENTRYPOINT ["ape"]
RUN ape --version
7 changes: 7 additions & 0 deletions Dockerfile.slim
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ COPY . .

RUN pip wheel .

RUN mkdir /wheels/recommended_plugins

COPY ./recommended-plugins.txt ./recommended-plugins.txt

RUN pip wheel .[recommended-plugins] --wheel-dir=/wheels/recommended_plugins

FROM python:${PYTHON_VERSION}-slim

# See http://label-schema.org for metadata schema
Expand All @@ -34,6 +40,7 @@ COPY --from=builder /wheels/*.whl /wheels/
RUN pip install --upgrade pip
RUN pip install /wheels/*.whl

COPY --from=builder /wheels/recommended_plugins/*.whl /wheels/
RUN ape --version

WORKDIR /home/harambe/project
Expand Down

0 comments on commit 4d29c3a

Please sign in to comment.