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

Add a dev target to Dockerfile, add a dev compose file #836

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
29 changes: 29 additions & 0 deletions container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,32 @@ USER karapace

HEALTHCHECK --interval=10s --timeout=30s --retries=3 --start-period=60s \
CMD python3 healthcheck.py http://localhost:$KARAPACE_PORT/_health || exit 1


FROM builder AS dev-builder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Introducing the new stages means we must update the release flow so that we don't start publishing dev images: https://github.com/Aiven-Open/karapace/blob/main/.github/workflows/container.yml.

Similarly, I think if we're to keep the two compose files, target must be specified in the existing one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple solution for this is simply to have the actual production stage come after the dev stage. This way, the default will always be the production one. And by correctly using dependencies, when building for the prod stage (implicitly or not), docker won't run any of the build code for dev.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like the best solution 👍


# Install dev dependencies.
COPY ./requirements/requirements-dev.txt /build/
COPY ./requirements/requirements-typing.txt /build/
RUN --mount=type=cache,target=/root/.cache/pip \
python3 -m pip install -r /build/requirements-dev.txt -r /build/requirements-typing.txt


# Dev build stage
FROM karapace AS dev

# Install linux dependencies
USER root

RUN apt-get update \
&& apt-get install --assume-yes --no-install-recommends \
openjdk-11-jdk \
&& rm -rf /var/lib/apt/lists/*

USER karapace


COPY --from=dev-builder /venv /venv

RUN mkdir /opt/karapace/app
ENV PYTHONPATH="/opt/karapace/app:${PYTHONPATH}"
aiven-anton marked this conversation as resolved.
Show resolved Hide resolved
29 changes: 29 additions & 0 deletions container/compose-dev.yml
gpkc marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
version: '3'
services:
karapace-registry:
build:
context: ..
dockerfile: container/Dockerfile
target: dev
volumes:
- ../:/opt/karapace/app

karapace-rest:
build:
context: ..
dockerfile: container/Dockerfile
target: dev
volumes:
- ../:/opt/karapace/app

karapace-dev:
build:
context: ..
dockerfile: container/Dockerfile
target: dev
volumes:
- ../:/opt/karapace/app
working_dir: /opt/karapace/app
depends_on:
- kafka
Loading