Skip to content

Commit

Permalink
Improve Dockerfile.test
Browse files Browse the repository at this point in the history
This commit adds more pacakge and system dependencies to the Dockerfile.test
as well as running coverage and domains unit tests as entrypoint. This is used
to test the image before uploading to quay.io.

Signed-off-by: Francisco Trivino <[email protected]>
  • Loading branch information
f-trivino committed Aug 9, 2023
1 parent 1e175cb commit 2802be3
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 7 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/gating.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ jobs:
${{ ( github.event_name != 'pull_request' && github.ref_type == 'tag' && format('{0}:{1}', env.IMAGE_REGISTRY_QUAY, github.ref_name) ) || '' }}
containerfiles: |
./Dockerfile.test
- name: PRINT images
run: |
sudo podman images
# yamllint enable rule:line-length

- name: Push to Repositories if PR is not from fork
id: push-to-repo
uses: redhat-actions/push-to-registry@v2
Expand All @@ -81,6 +83,14 @@ jobs:
github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
run: echo "Image pushed to ${{ steps.push-to-repo.outputs.registry-paths }}"

- name: deploy the service
run: |
sudo podman run --name=bridge -d \
--privileged \
-p 8000:8000 -p 3501:3500 -p 4701:81 -p 4430:443 \
--hostname bridge.ipa.test \
localhost:${{ env.IMAGE_TAG }}
pull-container:
name: Pull the ipa-tuura container if PR is not from fork
runs-on: ubuntu-latest
Expand Down
58 changes: 52 additions & 6 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Podmanfile for building bridge image in development mode, including Swagger.

FROM registry.fedoraproject.org/fedora:38
ENV TZ=Europe/Madrid

LABEL org.opencontainers.image.source=https://github.com/freeipa/ipa-tuura
LABEL org.opencontainers.image.description="IPA-tuura Container"
LABEL org.opencontainers.image.description="Fedora Bridge Development Image"

# Install dependencies
# Install system dependencies
RUN dnf -y update && dnf -y install \
dbus-daemon \
dbus-devel \
Expand All @@ -28,7 +30,51 @@ RUN dnf -y update && dnf -y install \
unzip \
&& dnf clean all

COPY . ipa-tuura
WORKDIR /ipa-tuura
RUN pip install -r src/install/requirements.txt
RUN python3 src/ipa-tuura/manage.py test
# Install bridge dependencies
RUN dnf -y update && dnf -y install \
openldap-clients \
sssd \
sssd-ldap \
sssd-ipa \
realmd \
freeipa-client \
oddjob-mkhomedir \
&& dnf clean all

# Copy the source code
RUN mkdir /www
COPY . /www/ipa-tuura

# Install project dependencies
RUN pip install -r /www/ipa-tuura/src/install/requirements.txt

# packaging up model changes
WORKDIR /www/ipa-tuura/src/ipa-tuura/
RUN python3 manage.py makemigrations
RUN python3 manage.py migrate

# ENV
ENV DJANGO_SUPERUSER_PASSWORD Secret123
ENV DJANGO_SUPERUSER_USERNAME scim
ENV DJANGO_SUPERUSER_EMAIL [email protected]

# Create user
RUN python3 manage.py createsuperuser --scim_username scim --noinput

# Configuration
RUN sed -i 's/ALLOWED_HOSTS = \[\]/ALLOWED_HOSTS = \['"'*'"'\]/g' root/settings.py

# Install Unit Test Dependencies
RUN pip install factory_boy coverage

# Create and enable bridge service in devel mode (via manage.py HTTP)
COPY bridge-devel.service /etc/systemd/system/bridge.service
RUN systemctl enable bridge

CMD [ "/sbin/init" ]

# WA
#RUN hostnamectl set-hostname bridge.ipa.test

# Run the unit tests for the integration domains app
# RUN coverage run manage.py test domains -v 2 && coverage report && coverage html
13 changes: 13 additions & 0 deletions bridge-devel.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=SCIMv2 Bridge Server
After=network.target

[Service]
Type=idle
WorkingDirectory=/www/ipa-tuura/src/ipa-tuura/
ExecStart=/usr/bin/python3 /www/ipa-tuura/src/ipa-tuura/manage.py runserver 0.0.0.0:8000
TimeoutStartSec=600
TimeoutStopSec=600

[Install]
WantedBy=multi-user.target

0 comments on commit 2802be3

Please sign in to comment.