|
| 1 | +FROM python:3.9.7-slim-buster as sdist |
| 2 | + |
| 3 | +LABEL maintainer= "[email protected]" |
| 4 | +LABEL org.opencontainers.image.title="Dispatch PyPI Wheel" |
| 5 | +LABEL org.opencontainers.image.description="PyPI Wheel Builder for Dispatch" |
| 6 | +LABEL org.opencontainers.image.url="https://dispatch.io/" |
| 7 | +LABEL org.opencontainers.image.source="https://github.com/netflix/dispatch" |
| 8 | +LABEL org.opencontainers.image.vendor="Netflix, Inc." |
| 9 | +LABEL org.opencontainers.image.authors= "[email protected]" |
| 10 | + |
| 11 | +# Get and set up Node for front-end asset building |
| 12 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 13 | + # Needed for fetching stuff |
| 14 | + ca-certificates \ |
| 15 | + wget \ |
| 16 | + && rm -rf /var/lib/apt/lists/* |
| 17 | + |
| 18 | +RUN set -x \ |
| 19 | + && wget --quiet -O - https://deb.nodesource.com/setup_16.x | bash - \ |
| 20 | + && apt-get install -y nodejs |
| 21 | + |
| 22 | +ARG SOURCE_COMMIT |
| 23 | +ENV DISPATCH_BUILD=${SOURCE_COMMIT:-unknown} |
| 24 | +LABEL org.opencontainers.image.revision=$SOURCE_COMMIT |
| 25 | +LABEL org.opencontainers.image.licenses="https://github.com/netflix/dispatch/blob/${SOURCE_COMMIT:-master}/LICENSE" |
| 26 | + |
| 27 | +ARG DISPATCH_LIGHT_BUILD |
| 28 | +ENV DISPATCH_LIGHT_BUILD=${DISPATCH_LIGHT_BUILD} |
| 29 | + |
| 30 | +RUN echo "DISPATCH_LIGHT_BUILD=${DISPATCH_LIGHT_BUILD}" |
| 31 | + |
| 32 | +COPY . /usr/src/dispatch/ |
| 33 | +RUN export YARN_CACHE_FOLDER="$(mktemp -d)" \ |
| 34 | + && cd /usr/src/dispatch \ |
| 35 | + && python setup.py bdist_wheel \ |
| 36 | + && rm -r "$YARN_CACHE_FOLDER" \ |
| 37 | + && mv /usr/src/dispatch/dist /dist |
| 38 | + |
| 39 | +# This is the image to be run |
| 40 | +FROM python:3.9.7-slim-buster |
| 41 | + |
| 42 | +LABEL maintainer= "[email protected]" |
| 43 | +LABEL org.opencontainers.image.title="Dispatch" |
| 44 | +LABEL org.opencontainers.image.description="Dispatch runtime image" |
| 45 | +LABEL org.opencontainers.image.url="https://github.com/netflix/dispatch" |
| 46 | +LABEL org.opencontainers.image.documentation="https://github.com/netflix/dispatch" |
| 47 | +LABEL org.opencontainers.image.source="https://github.com/netflix/dispatch" |
| 48 | +LABEL org.opencontainers.image.vendor="Netflix, Inc." |
| 49 | +LABEL org.opencontainers.image.authors= "[email protected]" |
| 50 | + |
| 51 | + |
| 52 | +# add our user and group first to make sure their IDs get assigned consistently |
| 53 | +RUN groupadd -r dispatch && useradd -r -m -g dispatch dispatch |
| 54 | + |
| 55 | +# Sane defaults for pip |
| 56 | +ENV PIP_NO_CACHE_DIR=off \ |
| 57 | + PIP_DISABLE_PIP_VERSION_CHECK=1 \ |
| 58 | + # Dispatch config params |
| 59 | + DISPATCH_CONF=/etc/dispatch |
| 60 | + |
| 61 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 62 | + # Needed for fetching stuff |
| 63 | + ca-certificates \ |
| 64 | + wget gnupg \ |
| 65 | + && rm -rf /var/lib/apt/lists/* |
| 66 | + |
| 67 | +RUN set -x \ |
| 68 | + && echo "deb http://apt.postgresql.org/pub/repos/apt buster-pgdg main" > /etc/apt/sources.list.d/pgdg.list \ |
| 69 | + && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - |
| 70 | + |
| 71 | +RUN set -x \ |
| 72 | + && wget --quiet -O - https://deb.nodesource.com/setup_12.x | bash - |
| 73 | + |
| 74 | +COPY --from=sdist /dist/*.whl /tmp/dist/ |
| 75 | +RUN set -x \ |
| 76 | + && buildDeps="" \ |
| 77 | + && apt-get update \ |
| 78 | + && apt-get install -y --no-install-recommends $buildDeps \ |
| 79 | + # remove internal index when internal plugins are seperated |
| 80 | + && pip install -U /tmp/dist/*.whl \ |
| 81 | + && apt-get purge -y --auto-remove $buildDeps \ |
| 82 | + # We install run-time dependencies strictly after |
| 83 | + # build dependencies to prevent accidental collusion. |
| 84 | + # These are also installed last as they are needed |
| 85 | + # during container run and can have the same deps w/ |
| 86 | + && apt-get install -y --no-install-recommends \ |
| 87 | + pkg-config postgresql-client-12 nodejs \ |
| 88 | + && apt-get clean \ |
| 89 | + && rm -rf /var/lib/apt/lists/* \ |
| 90 | + && npm install mjml |
| 91 | + |
| 92 | +EXPOSE 8000 |
| 93 | +VOLUME /var/lib/dispatch/files |
| 94 | + |
| 95 | +ENTRYPOINT ["dispatch"] |
| 96 | +CMD ["server", "start", "dispatch.main:app", "--host=0.0.0.0"] |
| 97 | + |
| 98 | +ARG SOURCE_COMMIT |
| 99 | +LABEL org.opencontainers.image.revision=$SOURCE_COMMIT |
| 100 | +LABEL org.opencontainers.image.licenses="https://github.com/netflix/dispatch/blob/${SOURCE_COMMIT:-master}/LICENSE" |
0 commit comments