Skip to content

Commit d191a4f

Browse files
committed
feat: make Nomad fully composable
1 parent 6064908 commit d191a4f

File tree

5 files changed

+28
-47
lines changed

5 files changed

+28
-47
lines changed

Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,14 @@ COPY --from=production-deps /app/node_modules /app/node_modules
4545
COPY --from=build /app/build /app
4646
# Copy root package.json for version info
4747
COPY package.json /app/version.json
48+
49+
# Copy docs and README for access within the container
4850
COPY admin/docs /app/docs
4951
COPY README.md /app/README.md
52+
53+
# Copy entrypoint script and ensure it's executable
54+
COPY install/entrypoint.sh /usr/local/bin/entrypoint.sh
55+
RUN chmod +x /usr/local/bin/entrypoint.sh
56+
5057
EXPOSE 8080
51-
CMD ["node", "./bin/server.js"]
58+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

admin/config/logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const loggerConfig = defineConfig({
1818
targets:
1919
targets()
2020
.pushIf(!app.inProduction, targets.pretty())
21-
.pushIf(app.inProduction, targets.file({ destination: "/app/storage/logs/admin.log" }))
21+
.pushIf(app.inProduction, targets.file({ destination: "/app/storage/logs/admin.log", mkdir: true }))
2222
.toArray(),
2323
},
2424
},

install/entrypoint.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
set -e
44

55
echo "Starting entrypoint script..."
6-
echo "Running wait-for-it.sh to ensure MySQL is ready..."
76

8-
# Use wait-for-it.sh to wait for MySQL to be available
9-
# wait-for-it.sh <host>:<port> [-t timeout] [-- command args]
10-
/usr/local/bin/wait-for-it.sh ${DB_HOST}:${DB_PORT} -t 60 -- echo "MySQL is up and running!"
7+
# Ensure required storage directories exist (volume may be freshly mounted)
8+
mkdir -p /app/storage/logs /app/storage/kb_uploads
119

1210
# Run AdonisJS migrations
1311
echo "Running AdonisJS migrations..."

install/install_nomad.sh

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,11 @@ GREEN='\033[1;32m' # Light Green.
3131
WHIPTAIL_TITLE="Project N.O.M.A.D Installation"
3232
NOMAD_DIR="/opt/project-nomad"
3333
MANAGEMENT_COMPOSE_FILE_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/main/install/management_compose.yaml"
34-
ENTRYPOINT_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/main/install/entrypoint.sh"
3534
SIDECAR_UPDATER_DOCKERFILE_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/main/install/sidecar-updater/Dockerfile"
3635
SIDECAR_UPDATER_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/main/install/sidecar-updater/update-watcher.sh"
3736
START_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/main/install/start_nomad.sh"
3837
STOP_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/main/install/stop_nomad.sh"
3938
UPDATE_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/main/install/update_nomad.sh"
40-
WAIT_FOR_IT_SCRIPT_URL="https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh"
41-
4239
script_option_debug='true'
4340
accepted_terms='false'
4441
local_ip_address=''
@@ -406,30 +403,6 @@ download_management_compose_file() {
406403
echo -e "${GREEN}#${RESET} Docker compose file configured successfully.\\n"
407404
}
408405

409-
download_wait_for_it_script() {
410-
local wait_for_it_script_path="${NOMAD_DIR}/wait-for-it.sh"
411-
412-
echo -e "${YELLOW}#${RESET} Downloading wait-for-it script...\\n"
413-
if ! curl -fsSL "$WAIT_FOR_IT_SCRIPT_URL" -o "$wait_for_it_script_path"; then
414-
echo -e "${RED}#${RESET} Failed to download the wait-for-it script. Please check the URL and try again."
415-
exit 1
416-
fi
417-
chmod +x "$wait_for_it_script_path"
418-
echo -e "${GREEN}#${RESET} wait-for-it script downloaded successfully to $wait_for_it_script_path.\\n"
419-
}
420-
421-
download_entrypoint_script() {
422-
local entrypoint_script_path="${NOMAD_DIR}/entrypoint.sh"
423-
424-
echo -e "${YELLOW}#${RESET} Downloading entrypoint script...\\n"
425-
if ! curl -fsSL "$ENTRYPOINT_SCRIPT_URL" -o "$entrypoint_script_path"; then
426-
echo -e "${RED}#${RESET} Failed to download the entrypoint script. Please check the URL and try again."
427-
exit 1
428-
fi
429-
chmod +x "$entrypoint_script_path"
430-
echo -e "${GREEN}#${RESET} entrypoint script downloaded successfully to $entrypoint_script_path.\\n"
431-
}
432-
433406
download_sidecar_files() {
434407
# Create sidecar-updater directory if it doesn't exist
435408
if [[ ! -d "${NOMAD_DIR}/sidecar-updater" ]]; then
@@ -580,8 +553,6 @@ ensure_docker_installed
580553
setup_nvidia_container_toolkit
581554
get_local_ip
582555
create_nomad_directory
583-
download_wait_for_it_script
584-
download_entrypoint_script
585556
download_sidecar_files
586557
download_helper_scripts
587558
download_management_compose_file

install/management_compose.yaml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Project N.O.M.A.D. management services Docker Compose configuration
2+
#
3+
# This compose file defines the admin server, database, and other supporting services required to run Project N.O.M.A.D.
4+
# You can use this with `docker-compose up -d` to start all the necessary services with a single command after installation.
5+
#
6+
# Note: we recommend leaving all of the environment variables as-is except for any "replaceme" values,
7+
# which must be updated for the admin server to start successfully. The default values are optimized for ease of installation and use,
8+
# but you can customize them as needed (e.g. changing ports, database connection details, log level, etc.)
19
name: project-nomad
210
services:
311
admin:
@@ -12,38 +20,35 @@ services:
1220
volumes:
1321
- /opt/project-nomad/storage:/app/storage
1422
- /var/run/docker.sock:/var/run/docker.sock # Allows the admin service to communicate with the Host's Docker daemon
15-
- ./entrypoint.sh:/usr/local/bin/entrypoint.sh
16-
- ./wait-for-it.sh:/usr/local/bin/wait-for-it.sh
1723
- nomad-update-shared:/app/update-shared # Shared volume for update communication
1824
environment:
1925
- NODE_ENV=production
2026
- PORT=8080
2127
- LOG_LEVEL=info
22-
- APP_KEY=replaceme
23-
- HOST=0.0.0.0
24-
- URL=replaceme
28+
- APP_KEY=replaceme # Needs to be at least 16 chars or will fail validation and container won't start!
29+
- HOST=0.0.0.0 # Leave this as is so the admin server listens all interfaces within the container - this doesn't affect how you access it from the host, it's just for internal container networking
30+
- URL=replaceme # Should be set to the URL you will access the admin interface at (e.g. http://localhost:8080 or http://192.168.1.x:8080)
2531
- DB_HOST=mysql
26-
- DB_PORT=3306
32+
- DB_PORT=3306 # If you change the MySQL port, make sure to update this accordingly
2733
- DB_DATABASE=nomad
2834
- DB_USER=nomad_user
29-
- DB_PASSWORD=replaceme
35+
- DB_PASSWORD=replaceme # Needs to match the MYSQL_PASSWORD in the mysql service!
3036
- DB_NAME=nomad
3137
- DB_SSL=false
3238
- REDIS_HOST=redis
33-
- REDIS_PORT=6379
39+
- REDIS_PORT=6379 # If you change the Redis port, make sure to update this accordingly
3440
depends_on:
3541
mysql:
3642
condition: service_healthy
3743
redis:
3844
condition: service_healthy
39-
entrypoint: ["/usr/local/bin/entrypoint.sh"]
4045
healthcheck:
4146
test: ["CMD", "curl", "-f", "http://localhost:8080/api/health"]
4247
interval: 30s
4348
timeout: 10s
4449
retries: 3
4550
dozzle:
46-
image: amir20/dozzle:v10.0
51+
image: amir20/dozzle:v10.0 # Dozzle is optional, but note that the "Service Logs & Metrics" link in Settings points to it. We recommend including it unless you have a specific reason not to
4752
container_name: nomad_dozzle
4853
restart: unless-stopped
4954
ports:
@@ -61,7 +66,7 @@ services:
6166
- MYSQL_ROOT_PASSWORD=replaceme
6267
- MYSQL_DATABASE=nomad
6368
- MYSQL_USER=nomad_user
64-
- MYSQL_PASSWORD=replaceme
69+
- MYSQL_PASSWORD=replaceme # Needs to match DB_PASSWORD in the admin service!
6570
volumes:
6671
- /opt/project-nomad/mysql:/var/lib/mysql
6772
healthcheck:
@@ -80,7 +85,7 @@ services:
8085
interval: 30s
8186
timeout: 10s
8287
retries: 3
83-
updater:
88+
updater: # Updater & disk-collector are lightweight sidecar containers that run alongside the admin container to handle updates and host disk usage collection, respectively.
8489
image: ghcr.io/crosstalk-solutions/project-nomad-sidecar-updater:latest
8590
pull_policy: always
8691
container_name: nomad_updater

0 commit comments

Comments
 (0)