Skip to content

Commit fcda563

Browse files
committed
Improve dev container
1 parent 21ca728 commit fcda563

8 files changed

+80
-49
lines changed

README.md

+64-27
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ Table of Contents:
5353
- [match specific access tokens](#match-specific-access-tokens)
5454
- [Development](#development)
5555
- [Docker](#docker)
56-
- [NodeJS](#nodejs)
56+
- [Install dependencies and run application in development mode](#install-dependencies-and-run-application-in-development-mode)
57+
- [Build docker image](#build-docker-image)
5758

5859
## Getting Started
5960

@@ -65,7 +66,9 @@ Run it with:
6566
docker run --name tmt2 -d -p 8080:8080 jensforstmann/tmt2
6667
```
6768

68-
Data will be written within the container to `/app/backend/storage`. To keep the files with different containers you can either specify a docker volume or a path on the local system:
69+
Data will be written within the container to `/app/backend/storage`.
70+
To keep the files with different containers
71+
you can either specify a docker volume or a path on the local system:
6972

7073
```sh
7174
# docker volume
@@ -79,7 +82,8 @@ The matches which are neither finished nor stopped will be loaded on application
7982

8083
### Create you first Match
8184

82-
After running the container you can open the web frontend: http://localhost:8080 (or at whatever ip/server your docker container runs on.)
85+
After running the container you can open the web frontend: http://localhost:8080
86+
(or at whatever ip/server your docker container runs on.)
8387

8488

8589

@@ -88,14 +92,19 @@ _Example screenshot: Create a new match from the web frontend (both dark and lig
8892

8993

9094

91-
Even without an admin token you can create and manage matches (but only your own ones). If you want to know your admin token (a random one is generated at startup) either take a look at the `access_tokens.json` file or take a look at the first lines of the log output (`docker logs tmt2`).
95+
Even without an admin token you can create and manage matches (but only your own ones).
96+
If you want to know your admin token (a random one is generated at startup)
97+
either take a look at the `access_tokens.json` file
98+
or take a look at the first lines of the log output (`docker logs tmt2`).
9299

93100

94101
### Ingame Chat Commands
95102

96103
While TMT watches a match the player ingame can use chat commands to communicate with TMT:
97104

98-
- `.team a` or `.team b` - you need to choose a team before you can execute any other commands, check the response in the chat to be sure you've joined the right one, also check the scoreboard (team names are visible there) if you're on the right side (CT/T)
105+
- `.team a` or `.team b` - you need to choose a team before you can execute any other commands,
106+
check the response in the chat to be sure you've joined the right one,
107+
also check the scoreboard (team names are visible there) if you're on the right side (CT/T)
99108
- during the map election process:
100109
- `.ban` - ban a map from the map pool
101110
- `.pick` - pick a map to be played
@@ -113,7 +122,8 @@ While TMT watches a match the player ingame can use chat commands to communicate
113122
- during the match
114123
- `.pause` - pause the match at the next freezetime (alias `.tech`)
115124
- `.unpause` - set your team as ready (alias `.ready` & `.rdy`)
116-
- `.tac` - like pause, but uses up a tactical timeout for that team (same as calling an ingame vote for a tactical timeout)
125+
- `.tac` - like pause, but uses up a tactical timeout for that team
126+
(same as calling an ingame vote for a tactical timeout)
117127

118128

119129

@@ -139,7 +149,8 @@ TMT_SAY_PREFIX="[TMT] "
139149

140150
## API
141151

142-
See [`backend/swagger.json`](backend/swagger.json). You might want to copy its content and paste it into https://editor.swagger.io/.
152+
See [`backend/swagger.json`](backend/swagger.json).
153+
You might want to copy its content and paste it into https://editor.swagger.io/.
143154

144155
See also the [`examples`](examples) folder.
145156

@@ -201,41 +212,67 @@ After starting the dev processes you can reach the backend & frontend at:
201212

202213
## Docker
203214

204-
Docker is recommended as it's easy to use and doesn't require any other software to be installed (if docker is already set up).
215+
Docker is recommended as it's easy to use and doesn't require any other software to be installed
216+
(if docker is already set up).
205217

206-
> Note for windows user: It's recommended to have docker installed **directly within** WSL (not using Windows Docker from WSL) or to run a Linux VM.
218+
> *Note for windows user:*
219+
>
220+
> For better performance it's recommended to have docker (and this repo)
221+
> installed **directly within** WSL (not using Windows Docker from WSL) or to run a Linux VM.
207222
208-
Init the dev environment:
209-
210-
./dev-container-init.sh
211-
212-
Start a docker container with port forwarding and hot reloading:
213-
214-
./dev-container-start.sh
223+
```shell
224+
# Linux:
225+
./dev-container.sh
226+
```
215227

228+
```powershell
229+
# Windows
230+
.\dev-container.ps1
231+
```
216232

217233

218-
## NodeJS
219234

220-
If you don't want to use docker or want to use NodeJS directly, you can do the following to setup a dev environment:
235+
## Install dependencies and run application in development mode
221236

222237
Install dependencies:
223238

224-
npm install
225-
cd backend
226-
npm install
227-
cd ../frontend
228-
npm install
239+
```sh
240+
npm install
241+
cd backend
242+
npm install
243+
cd ../frontend
244+
npm install
245+
```
229246

230247
Run backend with hot reloading:
231248

232-
cd backend
233-
npm run dev
249+
```sh
250+
cd backend
251+
npm run dev
252+
```
234253

235254
Run frontend with hot reloading:
236255

237-
cd frontend
238-
npm run dev
256+
```sh
257+
cd frontend
258+
npm run dev
259+
```
260+
261+
Run both backend and frontend with hot reloading:
262+
263+
```sh
264+
npm run dev
265+
```
266+
267+
268+
269+
## Build docker image
270+
271+
To build a docker image locally:
272+
273+
```sh
274+
docker build -t tmt2 .
275+
```
239276

240277

241278

dev-container-init.ps1

-3
This file was deleted.

dev-container-init.sh

-5
This file was deleted.

dev-container-start.ps1

-6
This file was deleted.

dev-container-start.sh

-8
This file was deleted.

dev-container.ps1

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Set-Location $PSScriptRoot
2+
3+
$TMT_PORT_BACKEND = $env:TMT_PORT_BACKEND ?? 8080
4+
$TMT_PORT_FRONTEND = $env:TMT_PORT_FRONTEND ?? 5173
5+
6+
docker run --name tmt2-dev-container -h tmt2-dev-container --rm -it -v .:/app -w /app -p ${TMT_PORT_BACKEND}:8080 -p ${TMT_PORT_FRONTEND}:5173 node:20 bash

dev-container.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
cd "$(dirname "$0")"
4+
5+
TMT_PORT_BACKEND="${TMT_PORT_BACKEND:-8080}"
6+
TMT_PORT_FRONTEND="${TMT_PORT_FRONTEND:-5173}"
7+
8+
docker run --name tmt2-dev-container -h tmt2-dev-container --rm -it -v .:/app -w /app -p ${TMT_PORT_BACKEND}:8080 -p ${TMT_PORT_FRONTEND}:5173 node:20 bash

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"author": "Jens Forstmann",
77
"license": "MIT",
88
"scripts": {
9+
"build": "cd backend && npm run build && cd ../frontend && npm run build",
10+
"dev": "cd backend && npm run dev & cd frontend && npm run dev",
911
"clean": "prettier --write .",
1012
"prettier-check": "prettier --check ."
1113
},

0 commit comments

Comments
 (0)