Browse Source

Merge 16b72c0e44 into 3e6f5b61a1

pull/7383/merge
Lewis Nixon 18 hours ago
committed by GitHub
parent
commit
1c68c83d48
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 12
      .devcontainer/Dockerfile
  2. 31
      .devcontainer/devcontainer.json
  3. 17
      .devcontainer/docker-compose.yml
  4. 24
      DEVELOPMENT.md

12
.devcontainer/Dockerfile

@ -0,0 +1,12 @@
FROM node:22-slim
# Match the build tooling used by the production Dockerfile (keep this
# list and the --no-install-suggests flag in sync with it) so native
# dependencies (e.g. Prisma) compile correctly inside the Dev Container
RUN apt-get update && apt-get install -y --no-install-suggests \
g++ \
git \
make \
openssl \
python3 \
&& rm -rf /var/lib/apt/lists/*

31
.devcontainer/devcontainer.json

@ -0,0 +1,31 @@
{
"name": "Ghostfolio",
"dockerComposeFile": [
"../docker/docker-compose.dev.yml",
"docker-compose.yml"
],
"service": "app",
"workspaceFolder": "/workspaces/ghostfolio",
"shutdownAction": "stopCompose",
"remoteUser": "node",
"forwardPorts": [3333, 4200],
"portsAttributes": {
"3333": {
"label": "API"
},
"4200": {
"label": "Client"
}
},
"postCreateCommand": "npm install",
"customizations": {
"vscode": {
"extensions": [
"angular.ng-template",
"esbenp.prettier-vscode",
"firsttris.vscode-jest-runner",
"nrwl.angular-console"
]
}
}
}

17
.devcontainer/docker-compose.yml

@ -0,0 +1,17 @@
services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
volumes:
- ..:/workspaces/ghostfolio:cached
- node_modules:/workspaces/ghostfolio/node_modules
command: sleep infinity
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
volumes:
node_modules:

24
DEVELOPMENT.md

@ -18,6 +18,30 @@
1. Open https://localhost:4200/en in your browser
1. Create a new user via _Get Started_ (this first user will get the role `ADMIN`)
### Dev Container
As an alternative to the manual _Setup_ above, [Visual Studio Code](https://code.visualstudio.com) users can develop inside a [Dev Container](https://containers.dev). It runs the application in a Docker container alongside [PostgreSQL](https://www.postgresql.org) and [Redis](https://redis.io), pre-installed with the required build tooling (Node.js 22, `g++`, `git`, `make`, `openssl`, `python3`).
#### Prerequisites
- [Docker](https://www.docker.com/products/docker-desktop)
- [Visual Studio Code](https://code.visualstudio.com) with the [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension
- Copy the file `.env.dev` to `.env` and populate it with your data (`cp .env.dev .env`)
**Info:** Use `.env.dev`, not `.env.example`, as the base for `.env`. After copying, change `DATABASE_URL` and `REDIS_HOST` to point to the service names `postgres` and `redis` instead of `localhost`.
#### Setup
1. Open the repository folder in Visual Studio Code
1. Run the command _Dev Containers: Reopen in Container_ (this builds the container and runs `npm install` automatically)
1. In the container's integrated terminal, run `npm run database:setup` to initialize the database schema
1. Start the [server](#start-server)
1. Start the client with `npm run start:client -- --host 0.0.0.0` instead of the usual command (see note below)
1. Open https://localhost:4200/en in your browser
1. Create a new user via _Get Started_ (this first user will get the role `ADMIN`)
**Info:** The client dev server binds to `localhost` by default, which is only reachable from within the container itself. Passing `--host 0.0.0.0` makes it listen on all interfaces so Visual Studio Code's forwarded port reaches it from your browser on the host. This is not required for the server, which already binds to `0.0.0.0` by default. The `start:client` script also passes `-o` to open a browser automatically; since there is no browser inside the container, this will harmlessly fail and can be ignored.
### Start Server
#### Debug

Loading…
Cancel
Save