Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/cyberstorm-remix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ The easiest way to run the full stack (Backend + Frontend) is using Docker.
(If you have some pre-existing containers, please do `docker compose -f docker-compose.remix.development.yml down -v` and `docker compose -f docker-compose.remix.development.yml up -d --build`)

4. **Open Browser**
- **Frontend**: [http://new.localhost](http://new.localhost)
- **Backend**: [http://localhost](http://localhost)
- **Frontend**: [http://new.thunderstore.localhost](http://new.thunderstore.localhost)
- **Backend**: [http://thunderstore.localhost](http://thunderstore.localhost)

## Manual Setup

Expand Down
18 changes: 9 additions & 9 deletions apps/cyberstorm-remix/entrypoint.dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ if [ -z "$(ls -A node_modules)" ] || [ ! -f node_modules/.bin/react-router ]; th
su node -c "yarn install --frozen-lockfile --production=false"
fi

# Map localhost to the backend nginx container IP so SSR API calls hit the backend
# without changing client-side env values.
# Map thunderstore.localhost to the backend nginx container IP so SSR API calls hit
# the backend without changing client-side env values.
backend_nginx_ip=$(getent hosts nginx | awk '{print $1}')
if [ -n "$backend_nginx_ip" ]; then
# Prepend to /etc/hosts to take precedence over the default loopback entry.
# Prepend to /etc/hosts so it takes precedence.
# Make idempotent to avoid duplicate lines on restarts.
if ! grep -q "^${backend_nginx_ip}[[:space:]][[:space:]]*localhost\([[:space:]]\|$\)" /etc/hosts 2>/dev/null; then
if ! grep -q "^${backend_nginx_ip}[[:space:]][[:space:]]*thunderstore\.localhost\([[:space:]]\|$\)" /etc/hosts 2>/dev/null; then
tmp_hosts=$(mktemp)
{
printf "%s localhost\n" "$backend_nginx_ip"
# Drop existing localhost mappings so the new mapping is unambiguous.
# This keeps other host entries intact.
awk '!($0 ~ /(^|[[:space:]])localhost([[:space:]]|$)/)' /etc/hosts 2>/dev/null || true
printf "%s thunderstore.localhost\n" "$backend_nginx_ip"
# Drop existing thunderstore.localhost mappings so the new mapping is unambiguous.
# This keeps other host entries (including localhost) intact.
awk '!($0 ~ /(^|[[:space:]])thunderstore\.localhost([[:space:]]|$)/)' /etc/hosts 2>/dev/null || true
} > "$tmp_hosts"
cat "$tmp_hosts" > /etc/hosts || printf "%s localhost\n" "$backend_nginx_ip" >> /etc/hosts
cat "$tmp_hosts" > /etc/hosts || printf "%s thunderstore.localhost\n" "$backend_nginx_ip" >> /etc/hosts
rm -f "$tmp_hosts"
fi
fi
Expand Down
20 changes: 10 additions & 10 deletions docker-compose.remix.development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ x-rsync-common: &rsync-common
- workspace_src:/workspace
- thunderstore_nginx_conf:/etc/nginx/user-conf
environment:
RSYNC_ARGS: "-a --delete --info=progress2 --exclude=.git --exclude=build-secrets --exclude=.npmrc --exclude=node_modules --exclude=.turbo --exclude=.cache --exclude=apps/cyberstorm-remix/build --exclude=apps/cyberstorm-remix/.react-router"
RSYNC_ARGS: "-a --delete --info=progress2 --exclude=.git --exclude=build-secrets --exclude=.npmrc --exclude=node_modules --exclude=.turbo --exclude=.cache --exclude=packages/*/dist --exclude=packages/*/dist/** --exclude=packages/*/types/dist --exclude=packages/*/types/dist/** --exclude=apps/cyberstorm-remix/build --exclude=apps/cyberstorm-remix/.react-router"
SYNC_INTERVAL: "5"

services:
Expand All @@ -15,7 +15,7 @@ services:
container_name: cyberstorm-remix-sync
restart: "no"
command: >-
/bin/sh -c "set -e; apk add --no-cache rsync; rsync $$RSYNC_ARGS /src/ /workspace/; tmp=/etc/nginx/user-conf/.new-localhost.conf.tmp; cp -f /src/tools/nginx/new-localhost.conf \"$$tmp\"; mv -f \"$$tmp\" /etc/nginx/user-conf/new-localhost.conf; echo sync complete"
/bin/sh -c "set -e; apk add --no-cache rsync; rsync $$RSYNC_ARGS /src/ /workspace/; tmp=/etc/nginx/user-conf/.new-thunderstore-localhost.conf.tmp; cp -f /src/tools/nginx/new-thunderstore-localhost.conf \"$$tmp\"; mv -f \"$$tmp\" /etc/nginx/user-conf/new-thunderstore-localhost.conf; echo sync complete"

cyberstorm-remix-watch:
<<: *rsync-common
Expand All @@ -25,7 +25,7 @@ services:
cyberstorm-remix-sync:
condition: service_completed_successfully
command: >-
/bin/sh -c "set -e; apk add --no-cache rsync; while true; do rsync $$RSYNC_ARGS /src/ /workspace/; tmp=/etc/nginx/user-conf/.new-localhost.conf.tmp; cp -f /src/tools/nginx/new-localhost.conf \"$$tmp\"; mv -f \"$$tmp\" /etc/nginx/user-conf/new-localhost.conf; sleep $$SYNC_INTERVAL; done"
/bin/sh -c "set -e; apk add --no-cache rsync; while true; do rsync $$RSYNC_ARGS /src/ /workspace/; tmp=/etc/nginx/user-conf/.new-thunderstore-localhost.conf.tmp; cp -f /src/tools/nginx/new-thunderstore-localhost.conf \"$$tmp\"; mv -f \"$$tmp\" /etc/nginx/user-conf/new-thunderstore-localhost.conf; sleep $$SYNC_INTERVAL; done"

cyberstorm-remix:
container_name: cyberstorm-remix
Expand All @@ -51,13 +51,13 @@ services:
- NPM_CONFIG_USERCONFIG=/run/secrets/npmrc
- ENABLE_BROKEN_PAGES=True
- VITE_DEVELOPMENT=True
- VITE_SITE_URL=http://localhost
- VITE_BETA_SITE_URL=http://new.localhost
- VITE_API_URL=http://localhost
- VITE_COOKIE_DOMAIN=.localhost
- VITE_AUTH_BASE_URL=http://localhost
- VITE_AUTH_RETURN_URL=http://new.localhost
- __VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS=.localhost
- VITE_SITE_URL=http://thunderstore.localhost
- VITE_BETA_SITE_URL=http://new.thunderstore.localhost
- VITE_API_URL=http://thunderstore.localhost
- VITE_COOKIE_DOMAIN=.thunderstore.localhost
- VITE_AUTH_BASE_URL=http://thunderstore.localhost
- VITE_AUTH_RETURN_URL=http://new.thunderstore.localhost
- __VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS=.thunderstore.localhost
secrets:
- npmrc

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ map $http_upgrade $connection_upgrade {

server {
listen 80;
server_name new.localhost;
server_name new.thunderstore.localhost;

# Resolve container DNS dynamically to avoid stale IPs.
resolver 127.0.0.11 ipv6=off valid=30s;

location / {
# Ensure requests to new.localhost are never served from the backend nginx proxy cache.
# Ensure requests to new.thunderstore.localhost are never served from the backend nginx proxy cache.
proxy_cache off;
proxy_cache_bypass 1;
proxy_no_cache 1;
Expand Down
Loading