Skip to content

Commit

Permalink
Update to use Docker Compose v2.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkhamez committed Aug 15, 2024
1 parent 48de44b commit 159bd6a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 30 deletions.
2 changes: 0 additions & 2 deletions docker-compose.yml → compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Creates a development environment

version: '3.5'

services:
neucore_db:
container_name: neucore_dev_db
Expand Down
19 changes: 10 additions & 9 deletions doc/Install.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,24 +290,25 @@ cd frontend && npm run build

### Docker Development Environment

Only tested on Linux and once or twice on macOS.
Needs [Docker Compose](https://docs.docker.com/compose/) V2. Only tested on Linux and once or
twice on macOS.

Copy `backend/.env.dist` file to `backend/.env` and adjust values, the database password and user are both `neucore`,
the database host is `neucore_db` and the database name also `neucore`.
Copy `backend/.env.dist` file to `backend/.env` and adjust values, the database password and user
are both `neucore`, the database host is `neucore_db` and the database name also `neucore`.

- Always run `export UID` first in each console that you use to execute any of the following commands.
- Build the containers:
`docker-compose build`
`docker compose build`
- Start services:
`docker-compose up`
`docker compose up`
- Install the app:
`setup/install-docker.sh`
`docker-compose exec neucore_node npm run build`
`docker compose exec neucore_node npm run build`
- After the first login, make the account with the ID 1 admin:
`docker-compose exec neucore_php bin/console make-admin 1`
`docker compose exec neucore_php bin/console make-admin 1`
- Run tests and other commands in the php and node containers:
`docker-compose exec neucore_php /bin/sh`
`docker-compose exec neucore_node /bin/sh`
`docker compose exec neucore_php /bin/sh`
`docker compose exec neucore_node /bin/sh`

The web application is available at http://localhost:8080, the frontend development server at http://localhost:3000.
The database is also available at `127.0.0.1:30306` and it's data is stored in the `.db` subdirectory.
Expand Down
2 changes: 1 addition & 1 deletion doc/api-examples/app-esi-examples.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
//

$coreHttpScheme = 'http';
$coreDomain = 'neucore_http'; // works with docker-compose
$coreDomain = 'neucore_http'; // Works with compose.yaml.
$coreAppToken = base64_encode('1:secret');
$coreCharId = '96061222'; // Character with token in Neucore

Expand Down
2 changes: 1 addition & 1 deletion frontend/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# Create an .env.development.local file to override the values if necessary.

# The backend domain, e.g. http://localhost:8080
# (BACKEND_HOST is defined in docker-compose.yml)
# (BACKEND_HOST is defined in compose.yaml)
VUE_APP_BACKEND_HOST=$BACKEND_HOST
16 changes: 8 additions & 8 deletions setup/dist-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ echo "NEUCORE_DATABASE_URL=mysql://user:@127.0.0.1/db?serverVersion=10.5.22-Mari

# Backend
cd "${DIR}"/.. || exit
docker-compose exec neucore_php sh -c "cd ../dist/build/backend && composer install --no-dev --optimize-autoloader --no-interaction"
docker-compose exec neucore_php sh -c "cd ../dist/build/backend && bin/doctrine orm:generate-proxies"
docker-compose exec neucore_php sh -c "cd ../dist/build/backend && composer openapi"
docker compose exec neucore_php sh -c "cd ../dist/build/backend && composer install --no-dev --optimize-autoloader --no-interaction"
docker compose exec neucore_php sh -c "cd ../dist/build/backend && bin/doctrine orm:generate-proxies"
docker compose exec neucore_php sh -c "cd ../dist/build/backend && composer openapi"

# OpenAPI JS client
cd "${DIR}"/.. || exit
docker-compose run neucore_java /app/dist/build/frontend/openapi.sh
docker-compose exec neucore_node sh -c "cd ../dist/build/frontend/neucore-js-client && npm install"
docker-compose exec neucore_node sh -c "cd ../dist/build/frontend/neucore-js-client && npm run build"
docker compose run neucore_java /app/dist/build/frontend/openapi.sh
docker compose exec neucore_node sh -c "cd ../dist/build/frontend/neucore-js-client && npm install"
docker compose exec neucore_node sh -c "cd ../dist/build/frontend/neucore-js-client && npm run build"

# Frontend
cd "${DIR}"/.. || exit
docker-compose exec neucore_node sh -c "cd ../dist/build/frontend && npm install"
docker-compose exec neucore_node sh -c "cd ../dist/build/frontend && npm run build"
docker compose exec neucore_node sh -c "cd ../dist/build/frontend && npm install"
docker compose exec neucore_node sh -c "cd ../dist/build/frontend && npm run build"

# Collect files and create archive
"${DIR}"/../dist/build/setup/dist-collect-files.sh
Expand Down
18 changes: 9 additions & 9 deletions setup/install-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
# Install backend, run database migrations and generate OpenAPI files.
cd "${DIR}"/.. || exit
if [[ $1 = prod ]]; then
docker-compose exec neucore_php composer install --no-dev --optimize-autoloader --no-interaction
docker-compose exec neucore_php composer compile:prod --no-dev --no-interaction
docker compose exec neucore_php composer install --no-dev --optimize-autoloader --no-interaction
docker compose exec neucore_php composer compile:prod --no-dev --no-interaction
else
docker-compose exec neucore_php composer install
docker-compose exec neucore_php composer compile
docker compose exec neucore_php composer install
docker compose exec neucore_php composer compile
fi

# Generate and build OpenAPI JavaScript client
docker-compose run neucore_java /app/frontend/openapi.sh
docker-compose exec neucore_node npm install --prefix /app/frontend/neucore-js-client
docker-compose exec neucore_node npm run build --prefix /app/frontend/neucore-js-client
docker compose run neucore_java /app/frontend/openapi.sh
docker compose exec neucore_node npm install --prefix /app/frontend/neucore-js-client
docker compose exec neucore_node npm run build --prefix /app/frontend/neucore-js-client


# Build frontend
docker-compose exec neucore_node npm install
docker compose exec neucore_node npm install
if [[ $1 = prod ]]; then
docker-compose exec neucore_node npm run build
docker compose exec neucore_node npm run build
fi

# Create database for unit tests
Expand Down

0 comments on commit 159bd6a

Please sign in to comment.