Skip to content

Commit eed310f

Browse files
committed
* Move rebuild functionality to dev-start.sh to avoid duplication
* Use "docker compose cp" to get the SSP sources from the container to the host in stead of using rsync
1 parent ffdc34c commit eed310f

6 files changed

Lines changed: 62 additions & 69 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
/container-files/simplesaml/
21
.idea/
2+
/container/

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,20 @@ When developing the OpenConect-devssp itself you can run devssp using the docker
3333

3434
Then go to [https://ssp.dev.openconext.local/](https://ssp.dev.openconext.local/).
3535
The proxy uses a self-signed certificate, so you will need to accept this certificate in your browser.
36-
37-
- `./dev-rebuild.sh` will rebuild the container and pull the latest base image
38-
39-
Both the `./dev-start.sh` and `./dev-rebuild.sh` scripts will copy the simplesaml directory from the container to `./container-files` on your host. This way you can use xdebug with the actual source files from the container by setting op a local path mapping in your IDE.
4036

41-
Then go to [https://ssp.dev.openconext.local/](https://ssp.dev.openconext.local/). The proxy uses a self-signed certificate, so you will need to accept this certificate in your browser.
37+
## dev-start.sh
38+
39+
You can use the `./dev-start.sh` script to start the containers in the background.
40+
Ths script will copy the contents of the `/var/www` directory in the container to the `container/var/www` directory on
41+
the host each time the container is started so that source debugging of these files is possible
42+
from the IDE.
43+
44+
With the `-r` option you can force a rebuild of the containers.
45+
```bash
46+
./dev-start.sh -r
47+
```
48+
49+
## Debugging
50+
The container has XDebug installed and configured.
4251

4352

container-files/scripts/sync.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

dev-rebuild.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.

dev-start.sh

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,56 @@ if [ ! -d "$DIR/../OpenConext-devconf/stepup/ssp" ]; then
1111
exit 1
1212
fi
1313

14-
# This script will start the Docker containers, rebuild the images
15-
# The --force-recreate flag will recreate the containers even if they are already running.
16-
# The --build flag will rebuild the devssp image
14+
# check commandline parameters:
15+
# -h or --help: show help
16+
# -r or --rebuild: force rebuild of the image and containers
17+
FORCE_REBUILD=0
18+
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
19+
echo "Usage: $0 [-r|--rebuild]"
20+
echo " -r, --rebuild Force rebuild of the image and containers"
21+
exit 0
22+
elif [[ "$1" == "-r" || "$1" == "--rebuild" ]]; then
23+
FORCE_REBUILD=1
24+
fi
1725

18-
echo "Rebuilding the devssp image and starting the containers..."
19-
docker compose up --force-recreate --build -d --wait
20-
echo "Containers are up"
26+
# Show hint if no parameters are given
27+
if [[ "$#" -eq 0 ]]; then
28+
echo "Staring the container. Use -h or --help for more options"
29+
echo ""
30+
fi
31+
32+
if [[ "$FORCE_REBUILD" -eq 1 ]]; then
33+
echo "Rebuilding the image and containers..."
34+
# This script will rebuild / pull Docker the docker images
35+
# then recreate and start the Docker containers
36+
echo "compose build --no-cache --pull"
37+
docker compose build --no-cache --pull
2138

22-
# execute the sync script in the container
23-
echo "Syncing the SSP installation directory to the host"
24-
docker compose exec -it ssp /scripts/sync.sh
25-
echo "Syncing done"
39+
# This script will start the Docker containers, rebuild the images
40+
# The --force-recreate flag will recreate the containers even if they are already running.
41+
# The --build flag will rebuild the devssp image
42+
echo "Rebuilding the devssp image and starting the containers..."
43+
docker compose up --force-recreate --build -d --wait
44+
else
45+
echo "Starting the containers..."
46+
docker compose up -d --wait
47+
fi
2648

49+
echo "Containers are up"
2750
echo "SSP is now available at https://ssp.dev.openconext.local/"
51+
echo ""
2852

29-
# attach to the containers's log output
30-
docker compose logs -f
53+
# Use docker compose cp to copy the /var/www directory from the ./container/ directory on the host
54+
echo "Copying the /var/www directory from the container to ./container"
55+
mkdir -p ./container/var/
56+
echo "docker compose cp devssp:/var/www ${DIR}/container/var/www"
57+
docker compose cp ssp:/var/www "${DIR}/container/var/"
58+
echo "Done."
59+
echo ""
3160

61+
# Attach to the container's log output
62+
echo "Following the logs of the containers... Use Ctrl+C to stop."
63+
echo "The containers will continue running in the background."
64+
echo ""
65+
echo "docker compose logs -f"
66+
docker compose logs -f

docker-compose.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ services:
1919
# Make the ssp configuration from OpenConext-devconf available in the container
2020
- ./../OpenConext-devconf/stepup/ssp:/var/www/simplesaml/config/cert/
2121

22-
# A copy of the /var/www/simplesaml/ directory to make this available to the host
23-
- ./container-files/simplesaml:/simplesaml/
24-
25-
# Contains the sync script that is used to make the copy.
26-
- ./container-files/scripts:/scripts/
27-
2822
networks:
2923
# create a local only network for the devssp container
3024
devsp_network:

0 commit comments

Comments
 (0)