Skip to content

Commit

Permalink
Bulk import & start organizing java files from 'triplea/triplea-game'
Browse files Browse the repository at this point in the history
  • Loading branch information
DanVanAtta committed Jun 22, 2024
1 parent 64fddbd commit b1859ac
Show file tree
Hide file tree
Showing 360 changed files with 17,651 additions and 17 deletions.
12 changes: 12 additions & 0 deletions .docker-compose/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
5 changes: 5 additions & 0 deletions .docker-compose/database/01-init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
create user lobby_user password 'lobby';
create database lobby_db owner lobby_user;

create user error_report_user password 'error_report';
create database error_report owner error_report_user;
57 changes: 57 additions & 0 deletions .docker-compose/nginx/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
server {
listen 80;
listen [::]:80;
server_name localhost;

location / {
proxy_pass http://lobby:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 90;
}

location /game-connection/ws {
proxy_pass http://lobby:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

location /player-connection/ws {
proxy_pass http://lobby:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}


location /game-support {
proxy_pass http://game-support-server:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 90;
}

location /maps {
proxy_pass http://maps-server:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 90;
}
}
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
FROM alpine:latest


#FROM openjdk:11-jre-slim-buster
#
#EXPOSE 8080
#ADD configuration.yml /
#ADD build/libs/triplea-dropwizard-server.jar /
#CMD java -jar triplea-dropwizard-server.jar server /configuration.yml
55 changes: 52 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ plugins {

apply plugin: "com.diffplug.spotless"

dependencies {
implementation("triplea:lobby-client:2.6.14756")
}

repositories {
mavenCentral()
Expand Down Expand Up @@ -40,3 +37,55 @@ spotless {
removeUnusedImports()
}
}

subprojects {

ext {
apacheHttpComponentsVersion = "4.5.14"
awaitilityVersion = "4.2.1"
bcryptVersion = "0.10.2"
caffeineVersion = "3.1.8"
checkstyleVersion = "8.45"
commonsCliVersion = "1.8.0"
commonsCodecVersion = "1.17.0"
commonsIoVersion = "2.16.1"
commonsMathVersion = "3.6.1"
commonsTextVersion = "1.12.0"
databaseRiderVersion = "1.42.0"
dropwizardVersion = "2.1.0"
dropwizardWebsocketsVersion = "1.3.14"
equalsVerifierVersion = "3.16.1"
feignCoreVersion = "13.2.1"
feignGsonVersion = "13.2.1"
javaWebSocketVersion = "1.5.3"
gsonVersion = "2.11.0"
guavaVersion = "33.2.1-jre"
hamcrestJsonVersion = "0.3"
hamcrestOptionalVersion = "2.0.0"
hamcrestVersion = "2.0.0.0"
jacksonDataTypeVersion = "2.17.1"
jakartaMailVersion = "2.0.1"
javaWebsocketVersion = "1.5.3"
javaxActivationVersion = "1.1.1"
jaxbApiVersion = "2.3.1"
jaxbCoreVersion = "4.0.5"
jaxbImplVersion = "4.0.5"
jdbiVersion = "3.45.1"
jetbrainsAnnotationsVersion = "24.1.0"
jlayerVersion = "1.0.1.4"
junitJupiterVersion = "5.10.2"
junitPlatformLauncherVersion = "1.10.2"
logbackClassicVersion = "1.2.11"
mockitoVersion = "5.11.0"
openFeignVersion = "13.2.1"
postgresqlVersion = "42.7.3"
snakeYamlVersion = "2.7"
sonatypeGoodiesPrefsVersion = "2.3.9"
substanceVersion = "4.5.0"
wireMockJunit5Version = "1.3.1"
wireMockVersion = "3.0.1"
xchartVersion = "3.8.8"
xmlUnitCore = "2.10.0"
xmlUnitMatchers = "2.10.0"
}
}
69 changes: 69 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# This docker-compose file depends on './gradlew shadowJar'
#
# Launches all of the background servers used by TripleA.
# The main entrypoint to those services is NGINX which
# is listening on localhost:80
#
version: '3'
services:
database:
image: postgres:10
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
volumes:
- ./.docker-compose/database/01-init.sql:/docker-entrypoint-initdb.d/01-init.sql
ports:
- "5432:5432"
healthcheck:
test: echo 'select 1' | psql -h localhost -U postgres | grep -q '1 row'
interval: 3s
retries: 10
timeout: 3s

lobby:
build:
context: spitfire-server/dropwizard-server/
dockerfile: Dockerfile
environment:
- DATABASE_USER=lobby_user
- DATABASE_PASSWORD=lobby
- DB_URL=database:5432/lobby_db
ports:
- "8080"
depends_on:
- database

game-support-server:
build:
context: servers/game-support/server/
dockerfile: Dockerfile
environment:
- DB_URL=database:5432/lobby_db
ports:
- "8080"
depends_on:
- database

maps-server:
build:
context: servers/maps/server/
dockerfile: Dockerfile
environment:
- DB_URL=database:5432/lobby_db
ports:
- "8080"
depends_on:
- database

nginx:
image: nginx:stable-alpine-perl
volumes:
- ./.docker-compose/nginx/default.conf:/etc/nginx/conf.d/default.conf
ports:
- "80:80"
links:
- game-support-server
- maps-server
- lobby
13 changes: 13 additions & 0 deletions http-clients/github-client/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
plugins {
id "java"
}

dependencies {
implementation "io.github.openfeign:feign-core:13.2.1"
implementation "io.github.openfeign:feign-gson:13.2.1"
// implementation project(":lib:feign-common")
// implementation project(":lib:java-extras")
testImplementation "ru.lanwen.wiremock:wiremock-junit5:1.3.1"
testImplementation "com.github.tomakehurst:wiremock:1.3.1"
// testImplementation project(":lib:test-common")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.triplea.http.client.github;

import com.google.gson.annotations.SerializedName;
import java.time.Instant;
import lombok.AllArgsConstructor;
import lombok.ToString;

/**
* Represents the data returned by github API for their 'branches' endpoint. This class Presents a
* simplified interface for what is otherwise a JSON response.
*/
@ToString
@AllArgsConstructor
public class BranchInfoResponse {
@SerializedName("commit")
private final LastCommit lastCommit;

/** Returns the date of the last commit. */
public Instant getLastCommitDate() {
return Instant.parse(lastCommit.commit.commitDetails.date);
}

@ToString
@AllArgsConstructor
private static class LastCommit {

private final Commit commit;

@ToString
@AllArgsConstructor
private static class Commit {
@SerializedName("author")
private final CommitDetails commitDetails;

@ToString
@AllArgsConstructor
private static class CommitDetails {
private final String date;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.triplea.http.client.github;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.triplea.http.client.HttpClientConstants;
import org.triplea.java.StringUtils;

/** Represents request data to create a github issue. */
@ToString
@EqualsAndHashCode
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CreateIssueRequest {
private String title;
private String body;
private String[] labels;

public String getTitle() {
return title == null ? null : StringUtils.truncate(title, HttpClientConstants.TITLE_MAX_LENGTH);
}

public String getBody() {
return body == null
? null
: StringUtils.truncate(body, HttpClientConstants.REPORT_BODY_MAX_LENGTH);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.triplea.http.client.github;

import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

/** Response JSON object from github after we create a new issue. */
@ToString
@AllArgsConstructor
@Getter
public class CreateIssueResponse {
@SerializedName("html_url")
private final String htmlUrl;
}
Loading

0 comments on commit b1859ac

Please sign in to comment.