Skip to content

Commit 098dcd1

Browse files
authored
Merge pull request #77 from OpenConext/feature/use-engine-migrations
Init EB DB using migrations instead of schema:create
2 parents 86f5dcd + 0e549a9 commit 098dcd1

3 files changed

Lines changed: 30 additions & 33 deletions

File tree

.github/workflows/stepup-behat.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
12-
timeout-minutes: 5
12+
timeout-minutes: 10
1313
env:
1414
DOCKER_COMPOSE: docker compose --profile smoketest -f docker-compose.yml
1515
steps:

core/README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,36 @@ This repo contains a docker compose and some configuration to get you started wi
88
## Getting started
99

1010
### The first time
11-
If you are doing this for the first time, you need to run a script to seed the environment:
11+
If you are doing this for the first time, first start the environment and then seed it:
1212

13+
1. Start the environment:
14+
```
15+
./start-dev-env.sh
16+
```
17+
18+
2. Once all containers are up, seed the environment:
1319
```
1420
./scripts/init.sh
1521
```
1622

1723
### After initialisation
18-
To get all services up and running you must have docker compose installed. Enter this command to get things up and running:
24+
To start the environment again after the initial setup:
1925

2026
```
21-
docker compose up -d
27+
./start-dev-env.sh
2228
```
2329

2430
You will also need to tell your local machine where to find the hosts.
25-
Add the following line in your hosts file (/etc/hosts )
31+
Add the following line in your hosts file (/etc/hosts):
2632
```
2733
127.0.0.1 engine.dev.openconext.local manage.dev.openconext.local profile.dev.openconext.local engine-api.dev.openconext.local mujina-idp.dev.openconext.local profile.dev.openconext.local connect.dev.openconext.local teams.dev.openconext.local voot.dev.openconext.local pdp.dev.openconext.local invite.dev.openconext.local welcome.dev.openconext.local
2834
```
2935

30-
If all goes wel, you can now login. Please see the section below to find out where you can login.
36+
If all goes well, you can now login. Please see the section below to find out where you can login.
3137

32-
*Please note that this starts the environment with the profile oidc. Bringing it down requires this command:*
38+
To bring the environment down:
3339
```
34-
docker compose --profile oidc down
40+
./stop-dev-env.sh
3541
```
3642

3743
## Services
@@ -68,10 +74,7 @@ Since the OpenConext suite is composed of multiple docker containers, you can us
6874
- invite: Starts services needed for Openconext-Invite (oidcng, voot and teams)
6975
- extras: Starts extras (currently pdp)
7076

71-
If you want to start all services, you can use extras. A profile can be started by using the --profile argument to the `docker compose up` command. For example:
72-
```
73-
docker compose up -d --profile extras
74-
```
77+
Profiles are handled automatically by `./start-dev-env.sh`. The `oidc` and `test` profiles are enabled by default. To enable additional profiles, edit the script directly.
7578

7679
# Starting a PHP project in development mode (only lifecycle, profile and engineblock)
7780

core/scripts/init.sh

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,26 @@ set -e
1212

1313
# Bootstrapping engineblock means initialising the database
1414
printf "\n"
15-
echo -e "${ORANGE}Bring up the engineblock container to bootstrap the database${NOCOLOR}"
16-
echo
1715

18-
# Wait for engine to come up; not health yet because we might nee to initialialize db
19-
docker compose up -d engine mariadb
16+
# Check that engine and mariadb are already running; containers must be started via ./start-dev-env.sh first
17+
engine_running=$(docker compose ps -q --status running engine mariadb | wc -l)
18+
if [[ "$engine_running" -lt 2 ]]; then
19+
echo -e "${RED}ERROR: engine and/or mariadb are not running.${NOCOLOR}"
20+
echo -e "${ORANGE}Please start the environment first by running:${NOCOLOR}"
21+
echo -e " ${GREEN}./start-dev-env.sh${NOCOLOR}"
22+
echo -e "Then re-run this script once the containers are up."
23+
exit 1
24+
fi
25+
echo -e "${ORANGE}Using the currently running engine container for migrations${NOCOLOR}"
2026
docker compose exec engine timeout 300 bash -c 'while [[ "$(curl -k -s -o /dev/null -w ''%{http_code}'' localhost/internal/info)" != "200" ]]; do sleep 5; done' || false
2127

2228
echo
2329
echo -e "${ORANGE}Initializing EB database$NOCOLOR ${VINKJE}"
2430
echo
25-
echo "Checking if the database is already present"
26-
if ! docker compose exec engine /var/www/html/bin/console doctrine:schema:validate -q --skip-mapping --env=prod > /dev/null
27-
then
28-
echo creating the database schema
29-
cmd='docker compose exec engine /var/www/html/bin/console doctrine:schema:update --force -q'
30-
#echo "Executing: ${cmd}"
31-
${cmd}
32-
fi
31+
echo "Running database migrations"
32+
cmd='docker compose exec engine /var/www/html/bin/console doctrine:migrations:migrate --no-interaction'
33+
${cmd}
34+
3335
echo "Clearing the cache"
3436
docker compose exec engine /var/www/html/bin/console cache:clear -n --env=prod
3537
docker compose exec engine chown -R www-data:www-data /var/www/html/var/cache/
@@ -42,14 +44,6 @@ do
4244
done
4345
echo -e " ${VINKJE}"
4446

45-
# Now it's time to bootstrap manage
46-
# Bring up containers needed for bootstrapping manage
47-
echo
48-
echo -e "${ORANGE}Bring up the core containers${NOCOLOR} ${VINKJE}"
49-
echo
50-
docker compose --profile oidc up -d --wait
51-
echo
52-
5347
echo -e "${ORANGE}Adding the manage entities${NOCOLOR} ${VINKJE}"
5448
printf "\n"
5549
for i in "$CWD"/*.json; do
@@ -87,5 +81,5 @@ echo "127.0.0.1 engine.dev.openconext.local manage.dev.openconext.local profile.
8781

8882
printf "\n"
8983
echo "You can now login. If you want to bring the environment down, use the command below"
90-
echo "docker compose --profile oidc down"
84+
echo "./stop-dev-env.sh"
9185
printf "\n"

0 commit comments

Comments
 (0)