[add] Adapted with alpine

This commit is contained in:
Pablo Aramburo 2022-10-11 16:34:58 -06:00
parent 983ce03fc8
commit 8332bcb0f8
3 changed files with 2008 additions and 31 deletions

View File

@ -1,25 +1,35 @@
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9-alpine3.14
WORKDIR /app/
# Install Poetry
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \
cd /usr/local/bin && \
ln -s /opt/poetry/bin/poetry && \
poetry config virtualenvs.create false
# Copy poetry.lock* in case it doesn't exist in the repo
COPY ./app/pyproject.toml ./app/poetry.lock* /app/
ENV PYTHONPATH=/app
# Allow installing dev dependencies to run tests
ARG INSTALL_DEV=false
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi"
# For development, Jupyter remote kernel, Hydrogen
# Using inside the container:
# jupyter lab --ip=0.0.0.0 --allow-root --NotebookApp.custom_display_url=http://127.0.0.1:8888
ARG INSTALL_JUPYTER=false
RUN bash -c "if [ $INSTALL_JUPYTER == 'true' ] ; then pip install jupyterlab ; fi"
WORKDIR /app/
# Copy poetry.lock* in case it doesn't exist in the repo
COPY ./app/pyproject.toml ./app/poetry.lock* /app/
RUN apk add --no-cache --virtual .build-deps curl g++ libffi-dev openssl-dev python3-dev libxslt-dev rust cargo && \
apk add --no-cache postgresql-dev && \
# Installing Poetry
curl -sSL https://install.python-poetry.org | python3 - && \
ln -s /root/.local/bin/poetry && \
/root/.local/bin/poetry config virtualenvs.create false && \
# Installing python dependencies
cd /app/ && \
sh -c "if [ $INSTALL_DEV == 'true' ] ; then /root/.local/bin/poetry install --no-root --no-interaction --no-ansi ; else /root/.local/bin/poetry install --no-root --no-interaction --no-ansi --only main ; fi" && \
# Installing jupyter notebooks
sh -c "if [ $INSTALL_JUPYTER == 'true' ] ; then pip install jupyterlab ; fi" && \
# Cleanup
# rm -r /root/.cargo && \
/root/.local/bin/poetry cache clear repository --all && \
apk --purge del .build-deps
COPY ./app /app
ENV PYTHONPATH=/app

View File

@ -1,25 +1,25 @@
FROM python:3.7
FROM python:3.7-alpine
WORKDIR /app/
# Install Poetry
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \
cd /usr/local/bin && \
ln -s /opt/poetry/bin/poetry && \
poetry config virtualenvs.create false
# Copy poetry.lock* in case it doesn't exist in the repo
COPY ./app/pyproject.toml ./app/poetry.lock* /app/
# Allow installing dev dependencies to run tests
ARG INSTALL_DEV=false
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi"
# For development, Jupyter remote kernel, Hydrogen
# Using inside the container:
# jupyter lab --ip=0.0.0.0 --allow-root --NotebookApp.custom_display_url=http://127.0.0.1:8888
ARG INSTALL_JUPYTER=false
RUN bash -c "if [ $INSTALL_JUPYTER == 'true' ] ; then pip install jupyterlab ; fi"
RUN apk add --no-cache --virtual .build-deps curl g++ libffi-dev openssl-dev python3-dev libxslt-dev rust cargo && \
apk add --no-cache postgresql-dev && \
# Installing Poetry
curl -sSL https://install.python-poetry.org | python3 - && \
ln -s /root/.local/bin/poetry && \
/root/.local/bin/poetry config virtualenvs.create false && \
# Installing python dependencies
cd /app/ && \
sh -c "if [ $INSTALL_DEV == 'true' ] ; then /root/.local/bin/poetry install --no-root --no-interaction --no-ansi ; else /root/.local/bin/poetry install --no-root --no-interaction --no-ansi --only main ; fi" && \
# Installing jupyter notebooks
sh -c "if [ $INSTALL_JUPYTER == 'true' ] ; then pip install jupyterlab ; fi" && \
# Cleanup
# rm -r /root/.cargo && \
/root/.local/bin/poetry cache clear repository --all && \
apk --purge del .build-deps
ENV C_FORCE_ROOT=1
@ -32,4 +32,4 @@ COPY ./app/worker-start.sh /worker-start.sh
RUN chmod +x /worker-start.sh
CMD ["bash", "/worker-start.sh"]
CMD ["sh", "/worker-start.sh"]

1967
backend/poetry.lock generated Normal file

File diff suppressed because it is too large Load Diff