Skip to content

Commit

Permalink
Do not install dev dependencies in Docker image (#3369)
Browse files Browse the repository at this point in the history
* Do not install dev dependencies in Docker image

* Rename requirements.txt as constraints.txt

* Fix docs install
  • Loading branch information
leplatrem authored Jan 26, 2024
1 parent 425b97d commit b72a00b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
20 changes: 10 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ RUN bash build-kinto-admin.sh

FROM python:3.10-slim-bullseye as python-builder
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN apt-get update && apt-get install -y --no-install-recommends build-essential libpq-dev
COPY requirements.txt .
ARG KINTO_VERSION=1
ENV SETUPTOOLS_SCM_PRETEND_VERSION_FOR_KINTO=${KINTO_VERSION} \
PATH="/opt/venv/bin:$PATH"
COPY constraints.txt .
COPY pyproject.toml .
RUN pip install --upgrade pip && \
pip install -r requirements.txt && \
pip install -e ".[postgresql,memcached,monitoring]" -c constraints.txt && \
pip install kinto-attachment kinto-emailer httpie

FROM python:3.10-slim-bullseye
Expand All @@ -21,20 +24,17 @@ RUN groupadd --gid 10001 app && \
useradd --uid 10001 --gid 10001 --home /app --create-home app

WORKDIR /app
USER app

COPY --from=python-builder /opt/venv /opt/venv
COPY . /app
COPY --from=node-builder /kinto/plugins/admin/build ./kinto/plugins/admin/build

ARG KINTO_VERSION=1
ENV SETUPTOOLS_SCM_PRETEND_VERSION_FOR_KINTO=${KINTO_VERSION} \
KINTO_INI=/etc/kinto/kinto.ini \
ENV KINTO_INI=/etc/kinto/kinto.ini \
PORT=8888 \
PATH="/opt/venv/bin:$PATH"

RUN \
pip install -e /app[postgresql,memcached,monitoring] -c /app/requirements.txt && \
kinto init --ini $KINTO_INI --host 0.0.0.0 --backend=memory --cache-backend=memory
RUN kinto init --ini $KINTO_INI --host 0.0.0.0 --backend=memory --cache-backend=memory

USER app
# Run database migrations and start the kinto server
CMD kinto migrate --ini $KINTO_INI && kinto start --ini $KINTO_INI --port $PORT
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,35 @@ help:

all: install
install: $(INSTALL_STAMP)
$(INSTALL_STAMP): $(PYTHON) requirements.txt pyproject.toml
$(INSTALL_STAMP): $(PYTHON) constraints.txt pyproject.toml
$(VENV)/bin/pip install -U pip
$(VENV)/bin/pip install -Ue . -c requirements.txt
$(VENV)/bin/pip install -Ue . -c constraints.txt
touch $(INSTALL_STAMP)

$(PYTHON):
python3 -m venv $(VENV)

install-monitoring: $(INSTALL_STAMP) $(DEV_STAMP)
$(VENV)/bin/pip install -Ue ".[monitoring]" -c requirements.txt
$(VENV)/bin/pip install -Ue ".[monitoring]" -c constraints.txt

install-postgres: $(INSTALL_STAMP) $(DEV_STAMP)
$(VENV)/bin/pip install -Ue ".[postgresql]" -c requirements.txt
$(VENV)/bin/pip install -Ue ".[postgresql]" -c constraints.txt

install-memcached: $(INSTALL_STAMP) $(DEV_STAMP)
$(VENV)/bin/pip install -Ue ".[memcached]" -c requirements.txt
$(VENV)/bin/pip install -Ue ".[memcached]" -c constraints.txt

install-dev: $(INSTALL_STAMP) $(DEV_STAMP)
$(DEV_STAMP): $(PYTHON) requirements.txt
$(VENV)/bin/pip install -Ue ".[dev,test]" -c requirements.txt
$(DEV_STAMP): $(PYTHON) constraints.txt
$(VENV)/bin/pip install -Ue ".[dev,test]" -c constraints.txt
touch $(DEV_STAMP)

install-docs: $(DOC_STAMP)
$(DOC_STAMP): $(PYTHON) docs/requirements.txt
$(VENV)/bin/pip install -Ur docs/requirements.txt
$(VENV)/bin/pip install -r docs/requirements.txt
touch $(DOC_STAMP)

requirements.txt: requirements.in
pip-compile
constraints.txt: constraints.in
pip-compile -o constraints.txt constraints.in

build-kinto-admin: need-npm
scripts/build-kinto-admin.sh
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit b72a00b

Please sign in to comment.