Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not install dev dependencies in Docker image #3369

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading