Skip to content

Commit

Permalink
ADD django_sp in Docker-compose and revisited CI workflow (#97)
Browse files Browse the repository at this point in the history
* Update CI workflow + ADD django_sp in Docker-compose

* Update CI Workflow - Review 2

* Update CI Workflow - Review 2.1

* Update CI Workflow - Review 2.2

* Update CI workflow + Docker-compose (review 3.1)
  • Loading branch information
davidelongo-ey authored Dec 19, 2023
1 parent d03c902 commit 4ad448e
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 28 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*
# Add exception for the directories you actually want to include in the context
!example
!example_sp
!requirements.txt
!oids.conf
!build_spid_certs.sh
!build_spid_certs.sh
27 changes: 7 additions & 20 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,45 +26,32 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies
run: |
sudo apt update
sudo apt install -y libffi-dev libssl-dev python3-pip xmlsec1 procps libpcre3 libpcre3-dev
- name: Install dependencies
run: |
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install -r example_sp/djangosaml2_sp/requirements.txt
pip install spid-sp-test>=1.2.8
pip install flake8
pip install satosa_oidcop>=1.0
- name: Lint with flake8
run: |
## stop the build if there are Python syntax errors or undefined names
flake8 --count --select=E9,F63,F7,F82 --show-source --statistics example
## exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 --max-line-length 120 --count --exit-zero --statistics example
- name: run djangosaml2 SP
- name: Create docker-example folder
run: |
cd example_sp/djangosaml2_sp/
bash run.sh &
sleep 5
mkdir -p docker-example
cp -r example/. docker-example
- name: docker compose
run: |
cd Docker-compose
docker compose -f docker-compose.yml up -d
- name: djangosaml2 SP metadata to Proxy
run: |
wget http://localhost:8000/saml2/metadata -O example/metadata/sp/djangosaml2_sp.xml
- name: Create docker-example folder
run: |
mkdir -p docker-example
cp -r example/. docker-example
- name: run satosa-saml2spid
run: |
cd docker-example
mkdir -p metadata/idp
mkdir -p metadata/sp
- name: docker compose
run: |
cd Docker-compose
docker compose -f docker-compose.yml up -d
- name: Metadata proxy to djangosaml2 SP
run: |
wget --no-check-certificate https://localhost/Saml2IDP/metadata -O example_sp/djangosaml2_sp/saml2_sp/saml2_config/satosa-saml2spid.xml
Expand Down
31 changes: 26 additions & 5 deletions Docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
version: '3'
services:

satosa-mongo:
image: mongo
container_name: satosa-mongo
Expand Down Expand Up @@ -32,11 +31,33 @@ services:
ME_CONFIG_MONGODB_URL: mongodb://${MONGO_DBUSER}:${MONGO_DBPASSWORD}@satosa-mongo:27017/
networks:
- satosa-saml2spid

## START: PARTE NUOVA
django_sp:
build:
context: ../
args:
- NODE_ENV=local
dockerfile: example_sp/django.Dockerfile
container_name: django_sp
#restart: always
working_dir: /django_sp
entrypoint: "sh ../entrypoint.sh"
volumes:
- /usr/share/zoneinfo/Europe/Rome:/etc/localtime:ro
- ../example_sp/djangosaml2_sp:/django_sp:rw
ports:
- "8000:8000"
networks:
- satosa-saml2spid
## END: PARTE NUOVA
satosa-saml2spid:
#image: ghcr.io/italia/satosa-saml2spid:latest
image: satosa-saml2spid:latest
build: ../
#image: satosa-saml2spid:latest
build:
context: ../
args:
- NODE_ENV=local
dockerfile: satosa.Dockerfile
container_name: satosa-saml2spid
depends_on:
- satosa-mongo
Expand Down Expand Up @@ -129,4 +150,4 @@ volumes:

networks:
satosa-saml2spid:
name: satosa-saml2spid
name: satosa-saml2spid
19 changes: 19 additions & 0 deletions example_sp/django.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM alpine:3.18

RUN apk update
RUN apk add --update --no-cache tzdata
RUN cp /usr/share/zoneinfo/Europe/Rome /etc/localtime
RUN echo "Europe/Rome" > /etc/timezone
RUN apk del tzdata

COPY example_sp/djangosaml2_sp/requirements.txt /
COPY example_sp/entrypoint.sh /

WORKDIR /djangosaml2_sp

RUN apk add --update xmlsec-dev libffi-dev openssl-dev python3 py3-pip python3-dev procps git openssl build-base gcc wget bash jq yq \
&& pip3 install --upgrade pip setuptools --root-user-action=ignore

RUN pip list

RUN pip3 install -r ../requirements.txt --ignore-installed --root-user-action=ignore
2 changes: 2 additions & 0 deletions example_sp/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python -B manage.py migrate
python -B manage.py runserver 0.0.0.0:8000
5 changes: 3 additions & 2 deletions Dockerfile → satosa.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ LABEL org.opencontainers.image.authors=$AUTHORS \
org.opencontainers.image.source=$VCS_URL \
org.opencontainers.image.revision=$VCS_REF \
org.opencontainers.image.description="Docker Image di Satosa-Saml2Spid."

RUN apk update
RUN apk add --update --no-cache tzdata
RUN cp /usr/share/zoneinfo/Europe/Rome /etc/localtime
Expand All @@ -29,6 +29,7 @@ RUN apk add mailcap

COPY requirements.txt /


ENV BASEDIR="/satosa_proxy"

RUN apk add --update xmlsec libffi-dev openssl-dev python3 py3-pip python3-dev procps git openssl build-base gcc wget bash jq yq \
Expand All @@ -38,4 +39,4 @@ RUN apk add --update xmlsec libffi-dev openssl-dev python3 py3-pip python3-dev p

RUN pip list

WORKDIR $BASEDIR/
WORKDIR $BASEDIR/

0 comments on commit 4ad448e

Please sign in to comment.