Skip to content

Commit c1b6b09

Browse files
committed
Modular Design
Made the Docker Building Modular + Using hostname instead of 0.0.0.0
1 parent f9d7141 commit c1b6b09

9 files changed

Lines changed: 228 additions & 43 deletions

File tree

DockerFiles/Dockerfile.game_server

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,15 @@ RUN cp configuration_files/entrypoint.sh ./entrypoint.sh
5353

5454
RUN chmod +x entrypoint.sh
5555

56-
# Run all services in the background and keep HypixelCore in the foreground
57-
CMD ["sh", "entrypoint.sh"]
56+
# Copy the Forwarding Secret
57+
RUN cp configuration_files/forwarding.secret ./forwarding.secret
58+
59+
# Update resources.json with the forwarding secret
60+
RUN secret=$(cat ./forwarding.secret) && \
61+
jq --arg secret "$secret" '.["velocity-secret"] = $secret' ./configuration/resources.json > ./configuration/resources.json.tmp && \
62+
mv ./configuration/resources.json.tmp ./configuration/resources.json
63+
64+
# Set the settings.yml bind: ip: 'localhost' to bind: ip: '0.0.0.0'
65+
RUN sed -i "s/ip: 'localhost'/ip: '0.0.0.0'/" ./settings.yml
66+
67+
CMD ["sh", "entrypoint.sh"]

configuration/entrypoint.sh

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,5 @@ sed -i "s/secret: '.*'/secret: '$secret'/" ./settings.yml
1414
# Set the settings.yml bind: ip: 'localhost' to bind: ip: '0.0.0.0'
1515
sed -i "s/ip: 'localhost'/ip: '0.0.0.0'/" ./settings.yml
1616

17-
18-
# Clear any previously created Screens (Starting freshhh)
19-
screen -wipe
20-
21-
# Start services in separate screen sessions
22-
screen -dmS HypixelCore_ISLAND java --enable-preview -jar HypixelCore.jar SKYBLOCK_ISLAND
23-
sleep 20
24-
screen -dmS HypixelCore_HUB java --enable-preview -jar HypixelCore.jar SKYBLOCK_HUB
25-
screen -dmS HypixelCore_FARMING java --enable-preview -jar HypixelCore.jar SKYBLOCK_THE_FARMING_ISLANDS
26-
screen -dmS PROTOTYPE_LOBBY java --enable-preview -jar HypixelCore.jar PROTOTYPE_LOBBY
27-
screen -dmS BEDWARS_LOBBY java --enable-preview -jar HypixelCore.jar BEDWARS_LOBBY
28-
screen -dmS NanoLimbo java -jar NanoLimbo-1.9.8.jar
29-
screen -dmS ServiceAPI java -jar ServiceAPI.jar
30-
screen -dmS ServiceAuctionHouse java -jar ServiceAuctionHouse.jar
31-
screen -dmS ServiceBazaar java -jar ServiceBazaar.jar
32-
screen -dmS ServiceItemTracker java -jar ServiceItemTracker.jar
33-
screen -dmS ServiceParty java -jar ServiceParty.jar
34-
echo "Started all services with a total of: $(screen -ls | grep -c 'Detached') screens"
35-
36-
# Keep the container running
37-
tail -f /dev/null
17+
echo "$SERVICE_CMD"
18+
exec $SERVICE_CMD

configuration/resources.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"mongodb": "mongodb://localhost",
33
"redis-uri": "redis://localhost:6379",
44
"velocity-secret": "ixmSUgWOgvs7",
5+
"limbo-host-name": "0.0.0.0",
56
"limbo-port": "65535",
67
"pterodactyl-mode": false,
78
"spark": false,

configuration/resources.json.docker

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
"mongodb": "mongodb://hypixel_mongo:27017",
33
"redis-uri": "redis://hypixel_redis:6379",
44
"velocity-secret": "ixmSUgWOgvs7",
5+
"limbo-host-name": "nanolimbo",
56
"limbo-port": "65535",
67
"pterodactyl-mode": false,
78
"spark": false,
89
"require-authentication": false,
9-
"cross-version-support": true,
10-
"host-name": "hypixel_game_server",
10+
"cross-version-support": false,
11+
"host-name": "0.0.0.0",
1112
"transfer-timeout": "800",
1213
"sandbox-mode": true,
1314
"anticheat": true

docker-compose.yml

Lines changed: 192 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,27 +57,208 @@ services:
5757
retries: 5
5858
start_period: 10s
5959

60-
game_server:
60+
game_server_builder:
6161
build:
6262
context: .
6363
dockerfile: "./DockerFiles/Dockerfile.game_server"
64-
container_name: hypixel_game_server
64+
image: game_server_prepared
65+
container_name: game_server_builder
66+
volumes:
67+
- ./configuration:/app/configuration_files
68+
networks:
69+
- hypixel_network
70+
71+
hypixelcore_island:
72+
image: game_server_prepared
73+
container_name: hypixelcore_island
74+
restart: "unless-stopped"
75+
environment:
76+
SERVICE_CMD: java --enable-preview -jar HypixelCore.jar SKYBLOCK_ISLAND
6577
depends_on:
6678
proxy:
6779
condition: service_healthy
68-
ports:
69-
- "25566:25566"
70-
- "65535:65535"
71-
- "20000:20000"
80+
game_server_builder:
81+
condition: service_started
82+
volumes:
83+
- ./configuration:/app/configuration_files
84+
networks:
85+
- hypixel_network
86+
87+
hypixelcore_hub:
88+
image: game_server_prepared
89+
container_name: hypixelcore_hub
90+
restart: "unless-stopped"
91+
environment:
92+
SERVICE_CMD: java --enable-preview -jar HypixelCore.jar SKYBLOCK_HUB
93+
depends_on:
94+
proxy:
95+
condition: service_healthy
96+
game_server_builder:
97+
condition: service_started
98+
volumes:
99+
- ./configuration:/app/configuration_files
100+
networks:
101+
- hypixel_network
102+
103+
hypixelcore_farming:
104+
image: game_server_prepared
105+
container_name: hypixelcore_farming
106+
restart: "unless-stopped"
107+
environment:
108+
SERVICE_CMD: java --enable-preview -jar HypixelCore.jar SKYBLOCK_THE_FARMING_ISLANDS
109+
depends_on:
110+
proxy:
111+
condition: service_healthy
112+
game_server_builder:
113+
condition: service_started
114+
volumes:
115+
- ./configuration:/app/configuration_files
116+
networks:
117+
- hypixel_network
118+
119+
prototype_lobby:
120+
image: game_server_prepared
121+
container_name: prototype_lobby
122+
restart: "unless-stopped"
123+
environment:
124+
SERVICE_CMD: java --enable-preview -jar HypixelCore.jar PROTOTYPE_LOBBY
125+
depends_on:
126+
proxy:
127+
condition: service_healthy
128+
game_server_builder:
129+
condition: service_started
130+
volumes:
131+
- ./configuration:/app/configuration_files
132+
networks:
133+
- hypixel_network
134+
135+
# bedwars_lobby:
136+
# image: game_server_prepared
137+
# container_name: bedwars_lobby
138+
# restart: "unless-stopped"
139+
# environment:
140+
# SERVICE_CMD: java --enable-preview -jar HypixelCore.jar BEDWARS_LOBBY
141+
# depends_on:
142+
# proxy:
143+
# condition: service_healthy
144+
# game_server_builder:
145+
# condition: service_started
146+
# volumes:
147+
# - ./configuration:/app/configuration_files
148+
# networks:
149+
# - hypixel_network
150+
151+
# bedwars_game:
152+
# image: game_server_prepared
153+
# container_name: bedwars_game
154+
# restart: "unless-stopped"
155+
# environment:
156+
# SERVICE_CMD: java --enable-preview -jar HypixelCore.jar BEDWARS_GAME
157+
# depends_on:
158+
# proxy:
159+
# condition: service_healthy
160+
# game_server_builder:
161+
# condition: service_started
162+
# volumes:
163+
# - ./configuration:/app/configuration_files
164+
# networks:
165+
# - hypixel_network
166+
167+
nanolimbo:
168+
image: game_server_prepared
169+
container_name: nanolimbo
170+
restart: "unless-stopped"
171+
environment:
172+
SERVICE_CMD: java -jar NanoLimbo-1.9.8.jar
173+
depends_on:
174+
proxy:
175+
condition: service_healthy
176+
game_server_builder:
177+
condition: service_started
178+
volumes:
179+
- ./configuration:/app/configuration_files
180+
networks:
181+
- hypixel_network
182+
183+
service_api:
184+
image: game_server_prepared
185+
container_name: service_api
186+
restart: "unless-stopped"
187+
environment:
188+
SERVICE_CMD: java -jar ServiceAPI.jar
189+
depends_on:
190+
proxy:
191+
condition: service_healthy
192+
game_server_builder:
193+
condition: service_started
194+
volumes:
195+
- ./configuration:/app/configuration_files
196+
networks:
197+
- hypixel_network
198+
199+
service_auctionhouse:
200+
image: game_server_prepared
201+
container_name: service_auctionhouse
202+
restart: "unless-stopped"
203+
environment:
204+
SERVICE_CMD: java -jar ServiceAuctionHouse.jar
205+
depends_on:
206+
proxy:
207+
condition: service_healthy
208+
game_server_builder:
209+
condition: service_started
210+
volumes:
211+
- ./configuration:/app/configuration_files
212+
networks:
213+
- hypixel_network
214+
215+
service_bazaar:
216+
image: game_server_prepared
217+
container_name: service_bazaar
218+
restart: "unless-stopped"
219+
environment:
220+
SERVICE_CMD: java -jar ServiceBazaar.jar
221+
depends_on:
222+
proxy:
223+
condition: service_healthy
224+
game_server_builder:
225+
condition: service_started
226+
volumes:
227+
- ./configuration:/app/configuration_files
228+
networks:
229+
- hypixel_network
230+
231+
service_itemtracker:
232+
image: game_server_prepared
233+
container_name: service_itemtracker
234+
restart: "unless-stopped"
235+
environment:
236+
SERVICE_CMD: java -jar ServiceItemTracker.jar
237+
depends_on:
238+
proxy:
239+
condition: service_healthy
240+
game_server_builder:
241+
condition: service_started
242+
volumes:
243+
- ./configuration:/app/configuration_files
244+
networks:
245+
- hypixel_network
246+
247+
service_party:
248+
image: game_server_prepared
249+
container_name: service_party
250+
restart: "unless-stopped"
251+
environment:
252+
SERVICE_CMD: java -jar ServiceParty.jar
253+
depends_on:
254+
proxy:
255+
condition: service_healthy
256+
game_server_builder:
257+
condition: service_started
72258
volumes:
73259
- ./configuration:/app/configuration_files
74260
networks:
75261
- hypixel_network
76-
healthcheck:
77-
test: ["CMD", "curl", "-f", "http://localhost:25566"]
78-
interval: 10s
79-
timeout: 5s
80-
retries: 5
81262

82263
volumes:
83264
mongodb-data:

loader/src/main/java/net/swofty/loader/Hypixel.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
import java.util.concurrent.CompletableFuture;
3939
import java.util.concurrent.atomic.AtomicBoolean;
4040
import java.util.stream.Collectors;
41+
import java.net.InetAddress;
42+
4143

4244
public class Hypixel {
4345
@Getter
@@ -243,7 +245,8 @@ public void onFlag(UUID uuid, FlagType flagType) {
243245

244246
JSONObject registerMessage = new JSONObject()
245247
.put("type", serverType.name())
246-
.put("max_players", maxPlayers);
248+
.put("max_players", maxPlayers)
249+
.put("host", InetAddress.getLocalHost().getHostName());
247250

248251
// Add test flow information if this is a test flow server
249252
if (isTestFlow) {

velocity.extension/src/main/java/net/swofty/velocity/SkyBlockVelocity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public SkyBlockVelocity(ProxyServer tempServer, Logger tempLogger, @DataDirector
8989
plugin = this;
9090
server = tempServer;
9191

92-
limboServer = server.registerServer(new ServerInfo("limbo", new InetSocketAddress(Configuration.get("host-name"),
92+
limboServer = server.registerServer(new ServerInfo("limbo", new InetSocketAddress(Configuration.get("limbo-host-name"),
9393
Integer.parseInt(Configuration.get("limbo-port")))));
9494
}
9595

velocity.extension/src/main/java/net/swofty/velocity/gamemanager/GameManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ public class GameManager {
2323
@Getter
2424
private static Map<ServerType, ArrayList<GameServer>> servers = new HashMap<>();
2525

26-
public static GameServer addServer(ServerType type, UUID serverID, int port, int maxPlayers) {
26+
public static GameServer addServer(ServerType type, UUID serverID, String host, int port, int maxPlayers) {
2727
port = port == -1 ? getNextAvailablePort() : port; // if port is -1 then get next available port
28+
host = (host == null || host.isEmpty()) ? Configuration.get("host-name") : host; // if host is null then get from config
2829
RegisteredServer registeredServer = SkyBlockVelocity.getServer().registerServer(
29-
new ServerInfo(serverID.toString(), new InetSocketAddress(Configuration.get("host-name"), port))
30+
new ServerInfo(serverID.toString(), new InetSocketAddress(host, port))
3031
);
3132

3233
String rootName = maxPlayers <= 20 ? "mini" : "mega";

velocity.extension/src/main/java/net/swofty/velocity/redis/listeners/ListenerServerInitialized.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import net.swofty.commons.ServerType;
44
import net.swofty.commons.proxy.ToProxyChannels;
5+
import net.swofty.commons.Configuration;
56
import net.swofty.velocity.gamemanager.GameManager;
67
import net.swofty.velocity.redis.ChannelListener;
78
import net.swofty.velocity.redis.RedisListener;
@@ -18,10 +19,16 @@ public JSONObject receivedMessage(JSONObject message, UUID serverUUID) {
1819
if (message.has("port")) {
1920
port = message.getInt("port");
2021
}
21-
int maxPlayers = message.getInt("max_players");
2222

23-
GameManager.GameServer server = GameManager.addServer(type, serverUUID, port, maxPlayers);
23+
String host = message.has("host")
24+
? message.getString("host")
25+
: Configuration.get("host-name"); // fallback to config if not present
26+
27+
int maxPlayers = message.getInt("max_players");
2428

25-
return new JSONObject().put("port", server.registeredServer().getServerInfo().getAddress().getPort());
29+
GameManager.GameServer server = GameManager.addServer(type, serverUUID, host, port, maxPlayers);
30+
return new JSONObject()
31+
.put("host", server.registeredServer().getServerInfo().getAddress().getHostString())
32+
.put("port", server.registeredServer().getServerInfo().getAddress().getPort());
2633
}
2734
}

0 commit comments

Comments
 (0)