Skip to content

Commit 339c0c4

Browse files
committed
docker dev env setup
1 parent 0bed199 commit 339c0c4

File tree

9 files changed

+161
-93
lines changed

9 files changed

+161
-93
lines changed

.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"root": true
3+
}

apps/cyberstorm-remix/README.md

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
This quide expects you to have setup your Thunderstore Django project for development on some level. Please setup the Thunderstore project before continuing.
55

66
## Setup nginx proxy for local data ingress/egress
7-
1. Add the following to your hosts (on windows, google what how to achive same on other OS')
8-
```
9-
127.0.0.1 thunderstore.temp
10-
127.0.0.1 new.thunderstore.temp
11-
```
12-
13-
2. Boot up the nginx proxy with the following command; `docker compose -f tools/ts-dev-proxy/docker-compose.yml up`
7+
1. Make sure the `Thunderstore` backend repo and this repo live under the same parent directory (e.g. `C:\projects\Thunderstore` and `C:\projects\thunderstore-ui`).
8+
2. From `Thunderstore` run `docker compose up -d`.
9+
3. Seed the database plus the default `localhost`/`new.localhost`/`auth.localhost` Site objects with `docker compose exec django python manage.py setup_dev_env`.
10+
4. From this repo run `docker compose -f docker-compose.remix.development.yml up -d`. This starts the Remix dev server and a lightweight `nginx-configurator` helper that copies the `tools/nginx/*.conf` files into the shared `thunderstore_nginx_conf` volume exposed by the backend nginx container.
11+
5. Wait until the `cyberstorm-remix` container reports `react-router dev` in its logs. The backend nginx container automatically reloads whenever the shared config volume changes, so visiting `http://localhost` (Django) or `http://new.localhost` (Remix) works without editing your hosts file.
1412

15-
3. Boot up your Thunderstore backend and ensure it's running in port 81 (it's normally 80). The following [line](https://github.com/thunderstore-io/Thunderstore/blob/f06b9b438ea6e990881e60339d34bde1a480d073/docker-compose.yml#L123) in your Thunderstore projects docker-compose, should be `- "127.0.0.1:81:8000"`
13+
> **Note:** The compose file exports `SERVER_SIDE_API_URL=http://nginx` to the Remix container. This makes server-rendered API calls talk to the backend nginx container directly, while the browser continues to use `VITE_API_URL=http://localhost`.
1614
1715
## Setup Nimbus for development
1816

@@ -28,13 +26,13 @@ This quide expects you to have setup your Thunderstore Django project for develo
2826

2927
4. Add `.env.development` and/or `.env.production` files. You can copy the `.env` file, rename and edit the values to your needs. Here's a example of the file contents:
3028
```
31-
VITE_SITE_URL=http://thunderstore.temp
32-
VITE_BETA_SITE_URL=http://new.thunderstore.temp
33-
VITE_API_URL=http://thunderstore.temp
34-
VITE_COOKIE_DOMAIN=.thunderstore.temp
35-
VITE_AUTH_BASE_URL=http://thunderstore.temp
36-
VITE_AUTH_RETURN_URL=http://new.thunderstore.temp
37-
__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS=.thunderstore.temp
29+
VITE_SITE_URL=http://localhost
30+
VITE_BETA_SITE_URL=http://new.localhost
31+
VITE_API_URL=http://localhost
32+
VITE_COOKIE_DOMAIN=.localhost
33+
VITE_AUTH_BASE_URL=http://auth.localhost
34+
VITE_AUTH_RETURN_URL=http://new.localhost
35+
__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS=.localhost
3836
```
3937

4038
5. Run the build/start server script or the dev server script
@@ -51,18 +49,17 @@ yarn workspace @thunderstore/cyberstorm-remix dev --port 3000 --host 0.0.0.0
5149
```
5250

5351
## Finally
54-
You should now have the fully local Nimbus dev environment setup and running in `http://new.thunderstore.temp` and the Django site should be running in `http://thunderstore.temp`. You might need to go to `http://new.thunderstore.temp/communities` as Nimbus doesn't have a landing page yet.
52+
You should now have the fully local Nimbus dev environment setup and running in `http://new.localhost` and the Django site should be running in `http://localhost`. You might need to go to `http://new.localhost/communities` as Nimbus doesn't have a landing page yet.
5553

5654
# How to setup ts-proxy as a backend for this project
5755
**Keep in mind that when using the ts-proxy, the sessions and actions will be made against the actual production Thunderstore**
5856

59-
1. Open hosts file as administrator (`C:\Windows\System32\drivers\etc`) and add this `127.0.0.1 thunderstore.temp` there
60-
2. Download and install Docker and docker-compose. For windows people, Docker for Windows should be enough.
61-
3. Open up a terminal and navigate to `thunderstore-ui/tools/ts-proxy`
62-
4. Run `docker compose up`
63-
5. Add these to your `.env.development` or `.env.production`
57+
1. Download and install Docker and docker-compose. For windows people, Docker for Windows should be enough.
58+
2. Open up a terminal and navigate to `thunderstore-ui/tools/ts-proxy`
59+
3. Run `docker compose up`
60+
4. Add these to your `.env.development` or `.env.production`
6461
```
65-
PUBLIC_SITE_URL=http://thunderstore.temp
66-
PUBLIC_API_URL=http://thunderstore.temp:81
62+
PUBLIC_SITE_URL=http://localhost
63+
PUBLIC_API_URL=http://localhost
6764
```
68-
6. Run the Nimbus project normally
65+
5. Run the Nimbus project normally

apps/cyberstorm-remix/public/cyberstorm-static/scripts/beta-switch.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ const betaQA = {
2424
};
2525
const legacyDev = {
2626
protocol: "http://",
27-
hostname: "thunderstore.temp",
27+
hostname: "localhost",
2828
port: "",
29-
tld: "temp",
29+
tld: "localhost",
3030
};
3131
const betaDev = {
3232
protocol: "http://",
33-
hostname: "new.thunderstore.temp",
33+
hostname: "new.localhost",
3434
port: "",
35-
tld: "temp",
35+
tld: "localhost",
3636
};
3737
async function checkBetaRedirect(legacy, beta, goToBetaRoR2) {
3838
const legacyOnlyPages = [

docker-compose.remix.development.yml

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,39 @@ version: "3.8"
33
services:
44
cyberstorm-remix:
55
container_name: cyberstorm-remix
6-
command: /bin/sh -c "tail -f /dev/null"
7-
# command: yarn workspace @thunderstore/cyberstorm-remix dev --port 3000 --host 0.0.0.0
8-
build:
9-
context: "./"
10-
dockerfile: "apps/cyberstorm-remix/Dockerfile.development"
11-
secrets:
12-
- "npmrc"
13-
image: thunderstore/thunderstore-ui.cyberstorm-remix-development:${IMAGE_TAG:-dev}
6+
image: node:24.1.0-alpine3.21
7+
entrypoint: ["/bin/sh", "/entrypoint.sh"]
8+
working_dir: /workspace
149
ports:
1510
- "127.0.0.1:3000:3000"
1611
volumes:
17-
- remix_node_modules:/app/apps/cyberstorm-remix/node_modules
18-
- ./apps/cyberstorm-remix:/app/apps/cyberstorm-remix
19-
- ./packages:/app/packages
12+
- .:/workspace
13+
- remix_node_modules:/workspace/node_modules
14+
- remix_app_node_modules:/workspace/apps/cyberstorm-remix/node_modules
15+
- ./tools/scripts/cyberstorm-dev-entrypoint.sh:/entrypoint.sh:ro
2016
networks:
2117
- thunderstore_default
2218
environment:
2319
- NODE_ENV=development
20+
- SERVER_SIDE_API_URL=http://nginx
21+
secrets:
22+
- npmrc
2423

25-
remix-nginx-proxy:
26-
image: nginx
27-
container_name: remix-nginx-proxy
28-
restart: always
29-
ports:
30-
- "443:443"
31-
- "80:80"
24+
nginx-configurator:
25+
image: alpine:3.20
26+
container_name: remix-nginx-configurator
27+
command: /bin/sh -c "set -e; mkdir -p /etc/nginx/user-conf; while true; do cp /source/*.conf /etc/nginx/user-conf/ >/dev/null 2>&1 || true; sleep 2; done"
3228
volumes:
33-
- ./nginx/www:/var/www:ro
34-
- ./nginx/conf.d/remixdefault.conf:/etc/nginx/conf.d/default.conf:ro
35-
# - ./ssl:/etc/nginx/ssl:ro
36-
# - ./snippets:/etc/nginx/snippets:ro
37-
# - ./protect:/etc/nginx/protect:ro
38-
hostname: thunderstore.temp
39-
networks:
40-
- thunderstore_default
29+
- ./tools/nginx:/source:ro
30+
- thunderstore_nginx_conf:/etc/nginx/user-conf
31+
depends_on:
32+
- cyberstorm-remix
4133

4234
volumes:
4335
remix_node_modules:
36+
remix_app_node_modules:
37+
thunderstore_nginx_conf:
38+
external: true
4439

4540
secrets:
4641
npmrc:

packages/beta-switch/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ const betaQA: UrlStructure = {
3737

3838
const legacyDev: UrlStructure = {
3939
protocol: "http://",
40-
hostname: "thunderstore.temp",
40+
hostname: "localhost",
4141
port: "",
42-
tld: "temp",
42+
tld: "localhost",
4343
};
4444

4545
const betaDev: UrlStructure = {
4646
protocol: "http://",
47-
hostname: "new.thunderstore.temp",
47+
hostname: "new.localhost",
4848
port: "",
49-
tld: "temp",
49+
tld: "localhost",
5050
};
5151

5252
async function checkBetaRedirect(

packages/ts-uploader/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ accessible by node. This might not be the case by default, as the backend dev
7272
environment setup instructions assume the browser to handle localhost subdomains
7373
rather than instructing system-wide configuration for them.
7474

75-
If using the local backend dev environment, you will most likely need to
76-
configure local DNS rules that map `thunderstore.localhost` to `127.0.0.1` and
77-
then set `http://thunderstore.localhost` as your `TS_API_DOMAIN` value.
75+
If using the local backend dev environment, point `TS_API_DOMAIN` to `http://localhost`.
76+
Modern browsers resolve `localhost` without any hosts-file entries, so no extra DNS tweaks
77+
are required.
7878

7979
Additionally, for some reason jsdom XMLHttpRequest will fail to make proper
8080
requests to the `localhost:9000` domain (which is what the backend dev env will
8181
use by default for s3 pre-signed URL generation), so you might need to change
8282
the `USERMEDIA_S3_SIGNING_ENDPOINT_URL` to e.g.
83-
`http://thunderstore.localhost:9000/` or something else which is accessible by
83+
`http://localhost:9000/` or something else which is accessible by
8484
jsdom.

tools/nginx/new-localhost.conf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
map $http_upgrade $connection_upgrade {
2+
default upgrade;
3+
'' '';
4+
}
5+
6+
upstream remix_dev {
7+
server cyberstorm-remix:3000;
8+
keepalive 64;
9+
}
10+
11+
server {
12+
listen 80;
13+
server_name new.localhost;
14+
15+
location / {
16+
proxy_pass http://remix_dev;
17+
proxy_http_version 1.1;
18+
proxy_set_header Host localhost;
19+
proxy_set_header Upgrade $http_upgrade;
20+
proxy_set_header Connection $connection_upgrade;
21+
}
22+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
set -euo
3+
4+
WORKDIR="/workspace"
5+
NODE_HOME="/home/node"
6+
7+
apk add --no-cache libc6-compat >/dev/null
8+
9+
install -d -o node -g node "$WORKDIR/node_modules"
10+
11+
if [ -f /run/secrets/npmrc ]; then
12+
install -m 600 -o node -g node /run/secrets/npmrc "$NODE_HOME/.npmrc"
13+
fi
14+
15+
su node -c "
16+
cd $WORKDIR
17+
if [ ! -d node_modules ] || [ -z \"\$(ls -A node_modules 2>/dev/null)\" ]; then
18+
yarn install --frozen-lockfile --production=false
19+
fi
20+
yarn workspace @thunderstore/cyberstorm-remix dev --port 3000 --host 0.0.0.0
21+
"

0 commit comments

Comments
 (0)