Skip to content

Commit

Permalink
Build config: rename docker folder & docs update (triplea-game#12258)
Browse files Browse the repository at this point in the history
- Update docs with how to launch local services with docker
  compose.

- Rename folder: '.docker' -> 'docker'
  • Loading branch information
DanVanAtta authored Feb 3, 2024
1 parent 68fee44 commit dd1d118
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 124 deletions.
6 changes: 0 additions & 6 deletions .docker/compose-up.sh

This file was deleted.

43 changes: 0 additions & 43 deletions .docker/dip.sh

This file was deleted.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ subprojects {
// composeBuild is the same as running => docker compose -f .docker/full-stack.yml --ansi never -p triplea build
dockerCompose {
projectName = 'triplea'
useComposeFiles = ['.docker/docker-compose.yml' ]
useComposeFiles = ['docker/docker-compose.yml' ]
}

// compose builds need WAR files for packaging, so we must run the corresponding package (shadowJar) tasks
Expand Down
8 changes: 8 additions & 0 deletions docker/compose-up.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -e

scriptDir=$(realpath "$(dirname "$0")")
rootDir="$scriptDir/.."

"$rootDir/gradlew" composeUp
12 changes: 12 additions & 0 deletions docker/connect-to-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# Connect to a locally running database that was started up via docker-compose.

set -eu

DB_IP=$(docker inspect \
--format='{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' \
triplea-database-1)

export PGPASSWORD=postgres
psql -h "$DB_IP" -U postgres
4 changes: 2 additions & 2 deletions .docker/docker-compose.yml → docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ services:
context: ../servers/game-support/server/
dockerfile: Dockerfile
environment:
- DB_URL=database:5432/error_report
- DB_URL=database:5432/lobby_db
depends_on:
- database
maps-server:
build:
context: ../servers/maps/server/
dockerfile: Dockerfile
environment:
- DB_URL=database:5432/maps
- DB_URL=database:5432/lobby_db
depends_on:
- database
database:
Expand Down
File renamed without changes.
File renamed without changes.
86 changes: 43 additions & 43 deletions docs/development/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,69 +29,74 @@ If you are new to Open Source & Github:
## Compile and launch TripleA (CLI)

```bash
"./gradlew :game-app:game-headed:run"
```
# Build & Launch TripleA Game-Client
./gradlew :game-app:game-headed:run

For more detailed steps on building the project with CLI, see:
- [reference/cli-build-commands.md](cli-build-commands.md)
# Run all build checks
./verify

## Compile and launch TripleA (IDEA)
# Run formatting
./gradew spotlessApply

IDE setup has the needed configurations for the project to compile. There are checked in launchers that
IDEA should automatically find. Look in 'run configurations' to launch the game-client.
# Launch a Postgres DB, build & launch TripleA Servers
./gradlew composeUp

## Running build checks locally (CLI)
# Connect to locally running database
./docker/connect-to-db.sh

Verify will run all checks (including additional custom checks):
```
./verify
```
# Runs all tests that do not require database
./gradlew test

Tests are split between those that need a database (which runs on docker), vs those that do not.
./gradlew testWithDatabase

- `./gradlew test`: Runs all tests that do not require database
- `./gradlew testWithDatabase`: Runs tests that require a local database
- `./gradlew allTest`: Runs all tests
# Runs all tests
./gradlew allTest

# Run game-app tests
./game-app/run/check

## Run Formatting
# Run tests for a (sub)project
./gradlew :game-app:game-core:test

# Run a specific test
./gradlew :game-app:game-core:test --tests games.strategy.triplea.UnitUtilsTest

We use 'google java format', be sure to install the plugin in your IDE to properly format
from IDE. Everything can also be formatted from CLI:
# Runs a specific test method
./gradlew :game-app:game-core:test --tests games.strategy.triplea.UnitUtilsTest.multipleTransportedUnitsAreTransferred

# Run specific tests using wildcard (be sure to use quotes around wildcard)
./gradlew :game-app:game-core:test --tests 'games.strategy.triplea.UnitUtilsTest.*Units*'
```
./gradew spotlessApply

`gradle` uses caches heavily, thus, if nothing has changed, re-running a test will not actually run the test again.
To really re-execute a test use the `--rerun-tasks` option:
```
./gradlew --rerun-tasks :game-app:game-core:test
```

PR builds will fail if the code is not formatted.
## Run Formatting

We use 'google java format', be sure to install the plugin in your IDE to properly format from IDE.


## Code Conventions (Style Guide)

Full list of coding conventions can be found at: [reference/code-conventions](code-conventions)

Please be sure to check these out so that you can fit the general style of the project.

## Lobby Development

### Launch Local Database
## Lobby / Server Development

Local database is needed to run the servers (lobby).

```bash
## start database
./gradlew composeUp
Run:
```
./gradlew composeUp
./gradlew :game-app:game-headed:run
```
Nginx will be running on port 80 following the 'composeUp'.
All requests are sent to NGINX and then routed to the correct
docker container.

### Launch local lobby

Lobby can be launched via the checked-in run configurations from IDE, or from CLI:
```bash
./gradlew :spitfire-server:dropwizard-server:run
```
To connect to local lobby, from the game client:
- 'settings > testing > local lobby'
- play online
- click play online button
- use 'test:test' to login to local lobby as a moderator

### Working with database
Expand Down Expand Up @@ -139,11 +144,6 @@ save games from loading.

'@RemoteMethod' indicates methods invoked over network. The API of these methods may not change.

## Lots of Manual Testing Required

A lot of code is not automatically verified via tests. If reasonable tests can be added, do so!
Generally though even the smallest of changes will need to be manually and thoroughly tested
in a variety of maps and scenarios.

# FAQ - common problems

Expand Down
28 changes: 0 additions & 28 deletions docs/development/cli-build-commands.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class LobbySelectionViewData implements ViewData {
@Getter
enum LobbyChoice {
PROD("Latest Stable", () -> UrlConstants.PROD_LOBBY, true),
LOCAL("Local", () -> "http://localhost:8080", true),
LOCAL("Local", () -> "http://localhost", true),
OTHER("Other", () -> ClientSetting.lobbyUri.getValueOrThrow().toString(), false);

private final String displayString;
Expand Down

0 comments on commit dd1d118

Please sign in to comment.