Skip to content

Commit

Permalink
Fix docker build (#3088)
Browse files Browse the repository at this point in the history
* update docker-compose to docker compose

* remove obsolte version
  • Loading branch information
juliano authored Sep 9, 2024
1 parent 8ca0e7e commit 680e296
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 33 deletions.
2 changes: 1 addition & 1 deletion build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ fi

show_mem
echo "Tests completed. Shutting down"
time docker-compose down
time docker compose down
# for 2.12 publish coverage
if [[ $SCALA_VERSION == 2.12* ]]; then
echo "Coverage"
Expand Down
12 changes: 6 additions & 6 deletions build/m1/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ In order to get this project to build on a Mac with an M1 or later chip, you wil
## Setup
To get started - be sure to setup the databases needed for the build/test process. Do so by executing the following:

`docker-compose -f docker-compose-m1.yml --rm setup`
`docker compose -f docker-compose-m1.yml --rm setup`

Any time you want to re-setup your databases (i.e. you run `docker-compose down`) - you will need to run that command pointed at the right YAML.
Any time you want to re-setup your databases (i.e. you run `docker compose down`) - you will need to run that command pointed at the right YAML.

## Compile and Test
To start the build and run tests, its often best to skip the codegen tests as they can sometimes cause phantom errors. To do this, execute the following:

`docker-compose -f docker-compose-m1.yml run sbt sbt -Dmodules=db test`
`docker compose -f docker-compose-m1.yml run sbt sbt -Dmodules=db test`

Drop the `-Dmodules=db` if you want to run ALL the tests (and grab an adult beverage while it runs - it'll be a while). Check out the `build.sbt` for a list of the
various modules you can build together or independently.

## Stop Your Services - Don't Down them!
Be nice to your M1 system - stop your services - don't down them. Running `docker-compose -f docker-compose-m1.yml down` will stop AND remove all your services. What this means is the next time you want to run your tests again - you better run setup again or your tests will fail due to missing databases!
Be nice to your M1 system - stop your services - don't down them. Running `docker compose -f docker-compose-m1.yml down` will stop AND remove all your services. What this means is the next time you want to run your tests again - you better run setup again or your tests will fail due to missing databases!

If you plan to have some rapid build/test cycles - run: `docker-compose -f docker-compose-m1.yml stop` to stop your services. It will preserve the volumes that were created when you ran setup. It'll save you a good amount of time.
If you plan to have some rapid build/test cycles - run: `docker compose -f docker-compose-m1.yml stop` to stop your services. It will preserve the volumes that were created when you ran setup. It'll save you a good amount of time.

## Build With a Specific Scala Version
By default the build executes with Scala 2.13. Not horrible - but if you want to take advantage of the improved compiler of a more recent 2.x version of Scala you can specify that!
You can simply set the `quill.scala.version` when you start your build:

`docker-compose -f docker-compose-m1.yml run sbt sbt -Dquill.scala.version=2.13.6 -Dmodules=db test`
`docker compose -f docker-compose-m1.yml run sbt sbt -Dquill.scala.version=2.13.6 -Dmodules=db test`

Check out the [CONTRIBUTING](../../docs/CONTRIBUTING.md) guide for more details. Good luck!
4 changes: 2 additions & 2 deletions build/setup_bigdata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

set -e

time docker-compose up -d cassandra orientdb
time docker compose up -d cassandra orientdb

# import setup functions
. build/setup_db_scripts.sh

# setup cassandra in docker
send_script cassandra $CASSANDRA_SCRIPT cassandra-schema.cql
send_script cassandra ./build/setup_db_scripts.sh setup_db_scripts.sh
time docker-compose exec -T cassandra bash -c ". setup_db_scripts.sh && setup_cassandra 127.0.0.1 cassandra-schema.cql"
time docker compose exec -T cassandra bash -c ". setup_db_scripts.sh && setup_cassandra 127.0.0.1 cassandra-schema.cql"

echo "Databases are ready!"
6 changes: 3 additions & 3 deletions build/setup_databases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
set -e

echo "### Bringing Down Any Docker Containers that May Be Running ###"
time docker-compose down --rmi all
time docker compose down --rmi all

echo "### Bringing Up sqlserver, oracle, postgres, mysql Images ###"
time docker-compose up -d sqlserver oracle postgres mysql
time docker compose up -d sqlserver oracle postgres mysql
echo "### DONE Bringing Up sqlserver and oracle Images ###"

echo "### Checking Docker Images"
Expand All @@ -28,7 +28,7 @@ echo "### Running Setup for sqlserver ###"
# setup sqlserver in docker
send_script sqlserver $SQL_SERVER_SCRIPT sqlserver-schema.sql
send_script sqlserver ./build/setup_db_scripts.sh setup_db_scripts.sh
time docker-compose exec -T sqlserver bash -c ". setup_db_scripts.sh && setup_sqlserver 127.0.0.1 sqlserver-schema.sql"
time docker compose exec -T sqlserver bash -c ". setup_db_scripts.sh && setup_sqlserver 127.0.0.1 sqlserver-schema.sql"

# Can't do absolute paths here so need to do relative
mkdir sqlline/
Expand Down
4 changes: 2 additions & 2 deletions build/setup_db_scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function setup_sqlserver() {

# Do a simple netcat poll to make sure the oracle database is ready.
# All internal database creation and schema setup scripts are handled
# by the container and docker-compose steps.
# by the container and docker compose steps.

function setup_oracle() {
while ! nc -z $1 1521; do
Expand Down Expand Up @@ -164,7 +164,7 @@ function setup_oracle() {

function send_script() {
echo "Send Script Args: 1: $1 - 2 $2 - 3: $3"
docker cp $2 "$(docker-compose ps -q $1)":/$3
docker cp $2 "$(docker compose ps -q $1)":/$3
}

export -f setup_sqlite
Expand Down
4 changes: 2 additions & 2 deletions build/setup_mysql_postgres_databases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
set -e

echo "### Bringing Down Any Docker Containers that May Be Running ###"
time docker-compose down --rmi all
time docker compose down --rmi all

echo "### Bringing Up postgres, mysql Images ###"
time docker-compose up -d postgres mysql
time docker compose up -d postgres mysql

echo "### Checking Docker Images"
docker ps
Expand Down
2 changes: 0 additions & 2 deletions docker-compose-m1.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

services:
postgres:
image: postgres:9.6
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.7'

services:
postgres:
image: postgres:9.6
Expand Down
26 changes: 13 additions & 13 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ If you are running Linux, you should also install Docker Compose separately, as
After installing Docker and Docker Compose you have to setup databases:

```bash
docker-compose run --rm setup
docker compose run --rm setup
```

After that you are ready to build and test the project. The following steps describes how to test the project with
Expand All @@ -28,7 +28,7 @@ when running Docker on non-linux OS due to high IO overhead from running
To build and test the project:

```bash
docker-compose run --rm sbt sbt test
docker compose run --rm sbt sbt test
```

## Building Scala.js targets
Expand All @@ -41,15 +41,15 @@ The CI build also sets this `project quill-with-js` to force the Scala.js compil
If any file that creates a database schema was changed then you have to setup the databases again:

```bash
docker-compose down && docker-compose run --rm setup
docker compose down && docker compose run --rm setup
```

## Changing docker configuration

If `build/Dockerfile-sbt`, `build/Dockerfile-setup`, `docker-compose.yml` or any file used by them was changed then you have to rebuild docker images and to setup the databases again:

```bash
docker-compose down && docker-compose build && docker-compose run --rm setup
docker compose down && docker compose build && docker compose run --rm setup
```

## Tests
Expand All @@ -58,28 +58,28 @@ docker-compose down && docker-compose build && docker-compose run --rm setup

Run all tests:
```bash
docker-compose run --rm sbt sbt test
docker compose run --rm sbt sbt test
```

Run specific test:
```bash
docker-compose run --rm sbt sbt "test-only io.getquill.context.sql.SqlQuerySpec"
docker compose run --rm sbt sbt "test-only io.getquill.context.sql.SqlQuerySpec"
```

Run all tests in specific sub-project:
```bash
docker-compose run --rm sbt sbt "project quill-jdbc-zio" test
docker compose run --rm sbt sbt "project quill-jdbc-zio" test
```

Run specific test in specific sub-project:
```bash
docker-compose run --rm sbt sbt "project quill-sqlJVM" "test-only io.getquill.context.sql.SqlQuerySpec"
docker compose run --rm sbt sbt "project quill-sqlJVM" "test-only io.getquill.context.sql.SqlQuerySpec"
```

### Debugging tests
1. Run sbt in interactive mode with docker container ports mapped to the host:
```bash
docker-compose run --service-ports --rm sbt
docker compose run --service-ports --rm sbt
```

2. Attach debugger to port 15005 of your docker host. In IntelliJ IDEA you should create Remote Run/Debug Configuration,
Expand All @@ -97,8 +97,8 @@ In order to contribute to the project, just do as follows:
2. Build it locally
3. Code
4. Compile (file will be formatted)
5. Run the tests through `docker-compose run sbt sbt test`
6. If you made changes in *.md files, run `docker-compose run sbt sbt tut` to validate them
5. Run the tests through `docker compose run sbt sbt test`
6. If you made changes in *.md files, run `docker compose run sbt sbt tut` to validate them
7. If everything is ok, commit and push to your fork
8. Create a Pull Request, we'll be glad to review it

Expand Down Expand Up @@ -136,7 +136,7 @@ branch will be capable of becoming a pull-request.
To restart your database service with database ports exposed to your host machine run:

```bash
docker-compose down && docker-compose run --rm --service-ports setup
docker compose down && docker compose run --rm --service-ports setup
```

After that we need to set some environment variables in order to run `sbt` locally.
Expand Down Expand Up @@ -169,7 +169,7 @@ Finally, you can use `sbt` locally.

To restart the database services, rebuild them, and start with locally exposed ports run:

docker-compose down && docker-compose build && docker-compose run --rm --service-ports setup
docker compose down && docker compose build && docker compose run --rm --service-ports setup

Note: Make sure you have exposed all the ports as mentioned above.

Expand Down

0 comments on commit 680e296

Please sign in to comment.