Skip to content

Commit

Permalink
actions: add build docker images workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
hex-agon committed Jul 14, 2023
1 parent 04c446e commit e96e45a
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 2 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build Images

on: workflow_dispatch

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: temurin
java-version: 20
cache: maven

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build images
run: |
mvn package jib:build --no-transfer-progress --pl resources-server -am
mvn package jib:build --no-transfer-progress --pl login-server -am
mvn package jib:build --no-transfer-progress --pl game-server -am
20 changes: 20 additions & 0 deletions game-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,24 @@
<version>${jackson.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<configuration>
<from>
<image>${jib.base.image}</image>
</from>
<to>
<image>ghcr.io/hex-agon/game-server:latest</image>
</to>
<container>
<appRoot>/alter-pangya/game-server</appRoot>
</container>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,20 @@ class Room(
private var ownerUid = -1

private val playersLock = ReentrantLock()
private val players = ArrayList<RoomPlayer>() // TODO: we can't use a list because lists shuffle when elements are removed
private val players = ArrayList<RoomPlayer>()

fun addPlayer(player: Player) {
playersLock.withLock {
player.currentRoom = this
// TODO: check if there's enough capacity on the room
// TODO: if the player is allowed to join, first broadcast a room census add with the new player, then add the player to the room
players.add(RoomPlayer(player))

if (ownerUid == -1) {
ownerUid = findNewOwner()
LOGGER.debug("Room $id had no owner, ${player.nickname} is now the owner ($ownerUid)")
}
// TODO: Do we want to couple network logic with our room logic? If not, do it event based? (RoomPlayerJoin, RoomPlayerLeave etc...)
// for a practice room...
player.write(RoomReplies.roomSettings(this))
player.write(RoomReplies.joinAck(this))
Expand Down
20 changes: 20 additions & 0 deletions login-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,24 @@
<version>${jackson.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<configuration>
<from>
<image>${jib.base.image}</image>
</from>
<to>
<image>ghcr.io/hex-agon/login-server:latest</image>
</to>
<container>
<appRoot>/alter-pangya/login-server</appRoot>
</container>
</configuration>
</plugin>
</plugins>
</build>
</project>
12 changes: 12 additions & 0 deletions networking/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,16 @@
<classifier>linux-x86_64</classifier>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
13 changes: 12 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
<log4j2.version>2.20.0</log4j2.version>
<junit.version>5.9.3</junit.version>
<mockito.version>5.4.0</mockito.version>
</properties>

<jib.version>3.3.2</jib.version>
<jib.base.image>eclipse-temurin:20-jre-alpine</jib.base.image>
</properties>

<repositories>
<repository>
Expand Down Expand Up @@ -123,5 +125,14 @@
<version>3.1.2</version>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>${jib.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
23 changes: 23 additions & 0 deletions resources-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,27 @@
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<configuration>
<from>
<image>${jib.base.image}</image>
</from>
<to>
<image>ghcr.io/hex-agon/resources-server:latest</image>
</to>
<container>
<appRoot>/alter-pangya/resources-server</appRoot>
<ports>
<port>50009/tcp</port>
</ports>
</container>
</configuration>
</plugin>
</plugins>
</build>
</project>
12 changes: 12 additions & 0 deletions service-discovery/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,16 @@
<version>${lettuce.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

0 comments on commit e96e45a

Please sign in to comment.