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
17 changes: 10 additions & 7 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
FROM mcr.microsoft.com/devcontainers/java:17
FROM eclipse-temurin:17-jdk-jammy

RUN su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install gradle "
RUN apt-get update -y \
&& apt-get install -y curl wget tar git unzip ca-certificates gnupg \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
ENV GRADLE_USER_HOME=/home/gradle
RUN useradd -ms /bin/bash dev \
&& mkdir -p ${GRADLE_USER_HOME} \
&& chown -R dev:dev ${GRADLE_USER_HOME}

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
USER dev
WORKDIR /workspace
54 changes: 24 additions & 30 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,31 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/java-postgres
{
"name": "Java & PostgreSQL",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/java:1.6.0": {
"installGradle": "true"
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// This can be used to network with other containers or with the host.
"forwardPorts": [
1080, // Mailcatcher
5432, // PostgreSQL
8080, // Events
8082 // Adminer
"name": "events-dev",
"dockerComposeFile": [
"../docker-compose.yml",
"docker-compose.yml"
],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "gradle bootRun",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "root",
"service": "app",
"workspaceFolder": "/workspace",
"overrideCommand": true,
"customizations": {
"vscode": {
"extensions": [
"vmware.vscode-boot-dev-pack",
"vscjava.vscode-gradle",
"vscjava.vscode-java-pack"
]
"vscjava.vscode-java-pack",
"redhat.java",
"vscjava.vscode-gradle"
],
"settings": {
"java.configuration.runtimes": [
{
"name": "JavaSE-17",
"path": "/opt/java/openjdk"
}
],
"java.jdt.ls.java.home": "/opt/java/openjdk"
}
}
}
},
"forwardPorts": [3090],
"postCreateCommand": "git config --global --add safe.directory /workspace || true",
"remoteUser": "dev"
}
56 changes: 16 additions & 40 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,25 @@
version: "3.8"

volumes:
postgres-data:

services:
app:
container_name: javadev
build:
context: .
dockerfile: Dockerfile
environment:
SPRING_PROFILES_ACTIVE: devcontainer

volumes:
- ../..:/workspaces:cached

# Overrides default command so things don't shut down after the process ends.
dockerfile: .devcontainer/Dockerfile
container_name: events-app
working_dir: /workspace
command: sleep infinity

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:postgres

depends_on:
- postgres
- mailcatcher

postgres:
image: docker.io/library/postgres:latest
restart: unless-stopped
init: true
volumes:
- postgres-data:/var/lib/postgresql/data
- .:/workspace:cached
- gradle-cache:/home/dev/.gradle
- m2-cache:/home/dev/.m2
environment:
POSTGRES_USER: postgres
POSTGRES_DB: events
POSTGRES_HOST_AUTH_METHOD: trust

adminer:
image: docker.io/library/adminer:latest
restart: always
depends_on:
- postgres
SPRING_PROFILES_ACTIVE: dev,devcontainer
depends_on:
- db
- mailcatcher
- oidc
ports:
- "8082:8080"
- "3090:3090"

mailcatcher:
image: docker.io/schickling/mailcatcher:latest
restart: on-failure
network_mode: service:postgres
volumes:
gradle-cache:
m2-cache:
16 changes: 16 additions & 0 deletions .run/Application [dev].run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Application [dev]" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<option name="ACTIVE_PROFILES" value="dev" />
<module name="events.main" />
<option name="SPRING_BOOT_MAIN_CLASS" value="ch.wisv.events.EventsApplication" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="ch.wisv.events.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
16 changes: 16 additions & 0 deletions .run/Application [devcontainer].run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Application [devcontainer]" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<option name="ACTIVE_PROFILES" value="dev,devcontainer" />
<module name="events.main" />
<option name="SPRING_BOOT_MAIN_CLASS" value="ch.wisv.events.EventsApplication" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="ch.wisv.events.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Application [dev]",
"request": "launch",
"mainClass": "ch.wisv.events.EventsApplication",
"args": "--spring.profiles.active=dev"
},
{
"type": "java",
"name": "Application [devcontainer]",
"request": "launch",
"mainClass": "ch.wisv.events.EventsApplication",
"args": "--spring.profiles.active=dev,devcontainer"
}
]
}
12 changes: 0 additions & 12 deletions .vscode/tasks.json

This file was deleted.

91 changes: 90 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,95 @@ Uses [WISVCH/bootstrap-theme](https://github.com/WISVCH/bootstrap-theme) for sty

All the documentation is on [https://wisvch.github.io/events/](https://wisvch.github.io/events/).

## Development

You can work on Events in three different ways:

- **Dev Container** (containerized workspace + dependencies).
- **Bare metal development with services in Docker** (local IDE + `docker compose` dependencies).
- **All bare metal** (manual local setup of all dependencies).

### Option 1 – Dev Container (VS Code or IntelliJ)

1. **Prerequisites**
- Docker Desktop (Linux users: Docker Engine + Docker Compose v2).
- For VS Code: install the *Dev Containers* extension.
For IntelliJ IDEA: install JetBrains Gateway with the *Dev Containers* plugin.
2. **Open the workspace**
- VS Code: `Dev Containers: Rebuild and Reopen in Container`.
- IntelliJ: `File ▸ Open… ▸ .devcontainer/devcontainer.json` via Gateway.
3. The dev container boots the project plus all dependencies using the included Compose files. No local tooling besides Docker is required.
4. **Run the application** with the supplied run configurations:
- IntelliJ: select `Application [devcontainer]` in the dropdown at the top-right, then click the green play button.
- VS Code: `Run and Debug ▸ Application [devcontainer]` (Not `Application [dev]`).

While the container is running:

| Service | Host URL / Port | Notes |
| --- | --- | --- |
| Events app | http://localhost:3090/events | Main web app |
| PostgreSQL 15 | localhost:35433 | Primary database (`postgres/postgres`) |
| pgAdmin | http://localhost:3091 | `admin@example.com` / `admin` |
| Mailcatcher UI | http://localhost:3092 | Test inbox |
| Mailcatcher SMTP | localhost:3588 | SMTP endpoint for dev mail |
| Mock OIDC | http://localhost:3093 | Login provider for local auth flow |

The mock OIDC service includes two ready-made accounts:

| Username | Password | Roles |
| --- | --- | --- |
| `constantijn` | `pwd` | Admin (beheer) |
| `christiaan` | `pwd` | Standard user |

### Option 2 – Docker Compose Dependencies (Local IDE)

1. Install JDK 17, Docker Desktop/Compose, and your preferred editor.
2. Start the shared services:

```bash
docker compose up -d db pgadmin mailcatcher oidc
```

(Stop them with `docker compose down` when you are done.)
3. Open the project in VS Code or IntelliJ. The project is already Gradle based, so it will import automatically.
4. Run the backend with the supplied run configurations:
- IntelliJ: `Run ▸ Run 'Application [dev]'`.
- VS Code: `Run and Debug ▸ Application [dev]`.

All services listen on the same host ports listed in the table above.

### Option 3 – Manual Setup

Configure everything yourself only if you cannot run Docker:

1. **PostgreSQL** – create a database named `events` reachable via `localhost:35433` (or update the connection in `config/application-dev.yml`).
2. **Mail** – run a local SMTP server or update `spring.mail.*` in `config/application-dev.yml` with your provider.
3. **OIDC provider** – register a Keycloak or other OIDC issuer and update:

```yaml
spring:
security:
oauth2:
client:
registration:
wisvchconnect:
client-id: <client id>
client-secret: <client secret>
provider:
wisvchconnect:
issuer-uri: https://login.ch.tudelft.nl/realms/wisvch
```

4. **Mollie/CH Pay** – set `mollie.apikey`, and update `wisvch.chpay.*` endpoints/keys as needed.
5. **Base URL** – match `server.port` (usually `3090`) and `server.servlet.context-path` (`/events`).
6. Once the configuration is in place, build and run with:

```bash
./gradlew bootRun --args='--spring.profiles.active=dev'
```

or reuse the IDE run configurations.

## Contribution

If you want to contribute, awesome! First, pick an issue and self-assign it. Make your changes in a new branch, with the following naming convention:
Expand All @@ -18,4 +107,4 @@ Implementing a new feature? > "feature_short-description-of-feature"
Once you're satisfied with your changes, create a pull request and give it the label "ready for inspection". You can assign any of the maintainers
in specific or wait for someone to pick it up. Make sure to include tests and documentation.

Got stuck with your implementation? Create a pull request with an explanation and give it the label "help wanted".
Got stuck with your implementation? Create a pull request with an explanation and give it the label "help wanted".
1 change: 1 addition & 0 deletions config/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
!.gitignore
!application.yml.example
!application-test.yml
!application-dev.yml
!application-devcontainer.yml
Loading
Loading