Skip to content

Commit

Permalink
Drop base images
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobranco777 committed May 24, 2024
1 parent acc4ea1 commit d28e403
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 112 deletions.
61 changes: 0 additions & 61 deletions .github/workflows/container_base.yml

This file was deleted.

5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ codecov:
pytest -v --cov --cov-report=html && xdg-open htmlcov/index.html

# Build containers
.PHONY: container container-devel container-k8s container-k8s-devel
container:
podman build . -t ${CONT_TAG} -f containers/Dockerfile
container-base:
podman build . -t ${CONT_TAG}-base -f containers/Dockerfile_base
container-base-k8s:
podman build . -t ${CONT_TAG}-base-k8s -f containers/Dockerfile_base_k8s
container-devel:
podman build . -t ${CONT_TAG}-devel -f containers/Dockerfile_dev
container-k8s:
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,9 @@ By default, PCW runs on http://127.0.0.1:8000/

In [containers](containers/) folder you main find several Dockerfiles to build several different images:

- [Dockerfile_base](containers/Dockerfile_base) basic image based on [bci-python3.11](https://registry.suse.com/categories/bci-devel/repositories/bci-python311) image which contains all dependencies needed for PCW execution except k8s cleanup. Image used as base for final image with actual PCW code
- [Dockerfile_base_k8s](containers/Dockerfile_base_k8s) basic image based on [bci-python3.11](https://registry.suse.com/categories/bci-devel/repositories/bci-python311) image which contains all dependencies needed for k8s cleanup PCW execution. Image used as base for final image with actual PCW code
- [Dockerfile](containers/Dockerfile) image based on [Dockerfile_base](containers/Dockerfile_base) and can be used to run all PCW functionality except k8s cleanup
- [Dockerfile_k8s](containers/Dockerfile_k8s) image based on [Dockerfile_base_k8s](containers/Dockerfile_base_k8s) and can be used to run k8s cleanup
- [Dockerfile_k8s_dev](containers/Dockerfile_k8s_dev) and [Dockerfile_dev](containers/Dockerfile_dev) images which contains same set of dependencies as [Dockerfile](containers/Dockerfile) and [Dockerfile_k8s](containers/Dockerfile_k8s) and expecting PCW source code to be mounted as volumes. Very usefull for development experiments
- [Dockerfile](containers/Dockerfile) image based on [bci-python3.11](https://registry.suse.com/categories/bci-devel/repositories/bci-python311) and can be used to run all PCW functionality except k8s cleanup
- [Dockerfile_k8s](containers/Dockerfile_k8s) image based on [bci-python3.11](https://registry.suse.com/categories/bci-devel/repositories/bci-python311) and can be used to run k8s cleanup
- [Dockerfile_k8s_dev](containers/Dockerfile_k8s_dev) and [Dockerfile_dev](containers/Dockerfile_dev) images which contains same set of dependencies as [Dockerfile](containers/Dockerfile) and [Dockerfile_k8s](containers/Dockerfile_k8s) and expect PCW source code to be mounted as volumes. Very usefull for development experiments

## Running a container

Expand Down
7 changes: 6 additions & 1 deletion containers/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
FROM ghcr.io/suse/pcw_base_main:master
FROM registry.suse.com/bci/python:3.11

COPY requirements.txt /pcw/
RUN source /etc/os-release && zypper addrepo -G -cf "https://download.opensuse.org/repositories/SUSE:/CA/$VERSION_ID/SUSE:CA.repo" && \

Check failure on line 4 in containers/Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint

SC1091 info: Not following: File not included in mock.
zypper -n in ca-certificates-suse gcc libffi-devel && \
pip install --no-cache-dir wheel && pip install --no-cache-dir -r /pcw/requirements.txt && zypper clean && rm -rf /var/cache

# Copy program files only
COPY ocw /pcw/ocw/
Expand Down
6 changes: 0 additions & 6 deletions containers/Dockerfile_base

This file was deleted.

11 changes: 0 additions & 11 deletions containers/Dockerfile_base_k8s

This file was deleted.

7 changes: 6 additions & 1 deletion containers/Dockerfile_dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
FROM ghcr.io/suse/pcw_base_main:master
FROM registry.suse.com/bci/python:3.11

COPY requirements.txt /pcw/
RUN source /etc/os-release && zypper addrepo -G -cf "https://download.opensuse.org/repositories/SUSE:/CA/$VERSION_ID/SUSE:CA.repo" && \

Check failure on line 4 in containers/Dockerfile_dev

View workflow job for this annotation

GitHub Actions / hadolint

SC1091 info: Not following: File not included in mock.
zypper -n in ca-certificates-suse gcc libffi-devel && \
pip install --no-cache-dir wheel && pip install --no-cache-dir -r /pcw/requirements.txt && zypper clean && rm -rf /var/cache

ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 UWSGI_WSGI_FILE=/pcw/webui/wsgi.py UWSGI_MASTER=1
ENV UWSGI_HTTP_AUTO_CHUNKED=1 UWSGI_HTTP_KEEPALIVE=1 UWSGI_LAZY_APPS=1 UWSGI_WSGI_ENV_BEHAVIOR=holy
Expand Down
12 changes: 11 additions & 1 deletion containers/Dockerfile_k8s
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
FROM ghcr.io/suse/pcw_base_k8s:master
FROM registry.suse.com/bci/python:3.11

RUN zypper -n in gcc tar gzip kubernetes1.24-client aws-cli && zypper clean && rm -rf /var/cache

# Google cli installation
RUN curl -sf https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-415.0.0-linux-x86_64.tar.gz | tar -zxf - -C /opt \
&& /opt/google-cloud-sdk/bin/gcloud components install gke-gcloud-auth-plugin

# Install python dependences
COPY requirements_k8s.txt /pcw/
RUN pip install --no-cache-dir wheel && pip install --no-cache-dir -r /pcw/requirements_k8s.txt

# Copy program files only
COPY ocw /pcw/ocw/
Expand Down
12 changes: 11 additions & 1 deletion containers/Dockerfile_k8s_dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
FROM ghcr.io/suse/pcw_base_k8s:master
FROM registry.suse.com/bci/python:3.11

RUN zypper -n in gcc tar gzip kubernetes1.24-client aws-cli && zypper clean && rm -rf /var/cache

# Google cli installation
RUN curl -sf https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-415.0.0-linux-x86_64.tar.gz | tar -zxf - -C /opt \
&& /opt/google-cloud-sdk/bin/gcloud components install gke-gcloud-auth-plugin

# Install python dependences
COPY requirements_k8s.txt /pcw/
RUN pip install --no-cache-dir wheel && pip install --no-cache-dir -r /pcw/requirements_k8s.txt

ENV PATH ${PATH}:/opt/google-cloud-sdk/bin/

Expand Down
22 changes: 1 addition & 21 deletions tests/test_webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,34 +75,14 @@ def build_image(client, image_name, dockerfile):

@pytest.fixture
def image(random_port, client, tmp_path):
base_image_name = f"pcw-base{random_port}"
image_name = f"pcw-test{random_port}"

# Build base image
build_image(client, base_image_name, "containers/Dockerfile_base")

# We must change the FROM image in Dockerfile to use above image instead
with open("containers/Dockerfile", encoding="utf-8") as f:
lines = f.read().splitlines()
dockerfile = tmp_path / "Dockerfile"
with open(dockerfile, "x", encoding="utf-8") as f:
for line in lines:
if line.startswith("FROM"):
print(f"FROM {base_image_name}", file=f)
else:
print(line, file=f)

try:
build_image(client, image_name, dockerfile)
except Exception:
client.images.remove(base_image_name)
raise
build_image(client, image_name, "containers/Dockerfile")

yield image_name

# Cleanup
with contextlib.suppress(APIError, PodmanError):
client.images.remove(base_image_name)
client.images.remove(image_name)


Expand Down

0 comments on commit d28e403

Please sign in to comment.