Skip to content

Commit

Permalink
Devcontainer (#451)
Browse files Browse the repository at this point in the history
* initial commit devcontainer

* add devcontainer yml

* WIP: devcontainer

* External product url (#430)

* Add external product URL to Event

* Add rendering of external URL when there is one

* Add rendering of external URL on event page

* Fix double text in external product url field

* Add validation checking for both products and url in one event

* Add validation checking for both products and url in one event in admin panel

* Add migration for external_product_url in event table

* Update script.min

* Remove description from external url event in webshop overview

* Added feature to make sure users have to agree to the General terms a… (#432)

* Added feature to make sure users have to agree to the General terms and conditions

* Edited link to GTC.

* removed unnecessary margins from css

* Revert "Added feature to make sure users have to agree to the General terms a… (#432)" (#433)

This reverts commit 5a262b0.

* Add pull_request as workflow trigger for docker build and tests (#434)

* Added feature to make sure users have to agree to the General terms and Conditions (#435)

* Added feature to make sure users have to agree to the General terms and conditions

* Edited link to GTC.

* removed unnecessary margins from css

* fix and add tests

* refactoring

* added statement in mail that participant agreed to GTC

* Update src/main/java/ch/wisv/events/webshop/controller/WebshopCheckoutController.java

Co-authored-by: Julian van Dijk <[email protected]>

* Extracted link to GTC as variable

* Put GTC link in yml

---------

Co-authored-by: Julian van Dijk <[email protected]>

* Update docker.yml (#437)

* Add gtc checkbox to event page (#438)

* Feature/integrity (#440)

* Add jquery-3.2.1 sha

* Add jquery-3.2.1.slim sha

* Add popper.js sha

* Add datatables sha

* Bump nokogiri from 1.13.3 to 1.14.3 in /docs

Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.13.3 to 1.14.3.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](sparklemotion/nokogiri@v1.13.3...v1.14.3)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump activesupport from 6.0.4.6 to 6.0.6.1 in /docs

Bumps [activesupport](https://github.com/rails/rails) from 6.0.4.6 to 6.0.6.1.
- [Release notes](https://github.com/rails/rails/releases)
- [Changelog](https://github.com/rails/rails/blob/v7.0.4.2/activesupport/CHANGELOG.md)
- [Commits](rails/rails@v6.0.4.6...v6.0.6.1)

---
updated-dependencies:
- dependency-name: activesupport
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* Add sha

* Implement VAT (#436)

* Implement VAT

* Add VAT table

* Update tests

* Update tests

* Fix tests

* Round price on 2 decimals

* Fix test GTC:

* Add gtc checkbox to event page (#438)

* Update tests

* Fix test

* KLote test

* Add order vat tests

* Add enumerated to VatRate

* Add vat column migrations

* Update V202306030__Add_vat_fields.java

* Update V202306030__Add_vat_fields.java

* Fix Beheer group (#445)

* Fix/logo size (#444)

* Fix logo alignment in webshop

* Fix header in event view

* Feature/scanned progress (#443)

* Add ScannedCount to Attendence class

* Move calculating attendance from controller to service and repository

* Add attendance to model for event overview page

* Add Scanned Tickets progress bar to event overview page

* Fix alignment of text in progress bars

* Remove example value

* Implement apple wallet passes (#446)

* Fix product test data

* Implement Apple Wallet Passes

* Remove redundant code

* Add cascade to Ticket - Order relation

* Add name to passes (#447)

* Add walletpasses to email (#448)

* Add name to passes

* Add wallet passes to email

* Fix MailService (#449)

* Fix/mailservice (#450)

* Fix MailService

* Fix tests

* Add connect devtokens to devcontainer

* Add try-catch to seeder

* Add datarunners to devcontainer

* Update devcontainer

* Remove oidc

* Rename

* Rename dockerfile

* Change port to 80

* Revert cascade on ticket to all

* Update workflow

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Julian <[email protected]>
Co-authored-by: Robert van Dijk <[email protected]>
Co-authored-by: KasperVaessen <[email protected]>
Co-authored-by: Julian van Dijk <[email protected]>
Co-authored-by: Julian van Dijk <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
7 people authored Oct 12, 2023
1 parent bc2dc53 commit 2728d29
Show file tree
Hide file tree
Showing 18 changed files with 227 additions and 26 deletions.
10 changes: 10 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM mcr.microsoft.com/devcontainers/java:0-17

RUN su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install gradle "

# [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>

# [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
27 changes: 27 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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": {
"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,
80,
8082
],
// 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"
}
49 changes: 49 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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.
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: postgres:latest
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_DB: events
POSTGRES_HOST_AUTH_METHOD: trust

adminer:
image: adminer
restart: always
depends_on:
- postgres
ports:
- 8082:8080

mailcatcher:
image: schickling/mailcatcher
restart: on-failure
network_mode: service:postgres
8 changes: 4 additions & 4 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v3
with:
Expand All @@ -36,19 +36,19 @@ jobs:
- name: Test Coverage
run: ./gradlew jacocoTestReport jacocoFix --scan
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v4
with:
images: ghcr.io/wisvch/events
tags: type=sha, prefix={{date 'YYYYMMDD'}}-
- name: Build and push Docker image
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
tags: ${{ steps.meta.outputs.tags }}
Expand Down
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"java.compile.nullAnalysis.mode": "automatic",
"java.configuration.updateBuildConfiguration": "interactive"
}
12 changes: 12 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "bootRun",
"type": "shell",
"command": "gradle bootRun"
}
]
}
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext {
springBootVersion = '2.5.12'
springBootVersion = '2.5.15'
}
ext['log4j2.version'] = '2.17.2'
repositories {
Expand Down Expand Up @@ -104,8 +104,8 @@ dependencies {

jacocoTestReport {
reports {
xml.enabled true
html.enabled false
xml.required = true
html.required = false
}
}

Expand Down
1 change: 1 addition & 0 deletions config/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
!.gitignore
!application.yml.example
!application-test.yml
!application-devcontainer.yml
101 changes: 101 additions & 0 deletions config/application-devcontainer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
############## Production properties #############################################################
# This is the default property file which can be used as a template for default configuration. #
# Copy this file to `/config/application.properties`, with the runnable jar in the `/` directory #
##################################################################################################

spring:
datasource:
# DATABASE PROPERTIES
driverClassName: org.postgresql.Driver
# Change <MyDb> with the name of your database name
url: jdbc:postgresql://localhost:5432/events

# Username to log in to the database
# It's recommended to create a dedicated Database user instead of using the default postgres user
username: postgres

# Password to log in with <MyDbPassword> in database <MyDb>
password:

data.jpa.repositories.enabled: true

flyway:
enabled: false

jpa:
# Set to false in production to prevent spamming of console
show-sql: false
hibernate.type: trace
type: trace
database-platform: org.hibernate.dialect.PostgreSQLDialect
generate-ddl: true
hibernate.ddl-auto: update

# This setting defines the database creation/update behaviour. Change with caution.
properties.hibernate.default_schema: public

thymeleaf:
# THYMELEAF (ThymeleafAutoConfiguration)
check-template-location: true
suffix: .html
mode: HTML
encoding: UTF-8
content-type: text/html

web:
resources:
static-locations[0]: "file:src/main/resources/static/"
static-locations[1]: "classpath:/static/"

mail:
host: 127.0.0.1
port: 1025

security:
oauth2:
client:
provider:
wisvchconnect:
issuer-uri: https://connect.ch.tudelft.nl
clientUri: http://localhost:8080/events
registration:
wisvchconnect:
client-id: events-devcontainer
client-secret: AN6tZXQea8gFFfDgs_hoUDeiBXPh6CZuvZFE9kBgxzQ2MoHgVzWkPrtSMrNpn75Ems9v4iaz6gRFf0ECY4Q8YEE
scope:
- auth
- profile
- email
- openid
- auth

logging.level.web: DEBUG

# Spring mail
# Database migration automation. Set to false for development

# Serve connect
server:
port: 80
servlet.context-path: /

# CH Connect Configuration
wisvch.connect:
# Change <MyLDAPgroup> to a LDAP group you're in (e.g. hoothub, dienst2, etc.)
admin-groups:
- hoothub
- beheer
claimName: google_groups

# CH Events Configuration
wisvch.events:
image.path: http://localhost:8080/events/api/v1/documents/

# CH mollie api key
mollie:
apikey: test
clientUri: http://localhost:8080/events

links:
gtc: https://ch.tudelft.nl
passes: https://ch.tudelft.nl/passes
2 changes: 1 addition & 1 deletion config/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spring:
username: postgres

# Password to log in with <MyDbPassword> in database <MyDb>
password:
password:

data.jpa.repositories.enabled: true

Expand Down
5 changes: 0 additions & 5 deletions config/application.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ wisvch.connect:
wisvch.events:
image.path: http://localhost:8080/events/api/v1/documents/

# CH Payments Configuration
wisvch.payments:
issuerUri: http://localhost:9000/payments
clientUri: http://localhost:8080/events

# CH mollie api key
mollie:
apikey: test
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/ch/wisv/events/core/model/event/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import lombok.AccessLevel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Setter;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.format.annotation.DateTimeFormat;
Expand All @@ -29,6 +30,7 @@
*/
@Entity
@Data
@EqualsAndHashCode(exclude = {"products"})
public class Event {

/**
Expand Down Expand Up @@ -256,8 +258,4 @@ public boolean hasExternalProductUrl() {
public String toString() {
return this.title;
}

public int hashCode() {
return this.id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.springframework.stereotype.Component;

@Component
@Profile("dev")
@Profile({"dev", "devcontainer"})
@Order(value = 3)
public class CustomerTestDataRunner extends TestDataRunner {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.springframework.stereotype.Component;

@Component
@Profile("dev")
@Profile({"dev", "devcontainer"})
@Order(value = 2)
public class EventTestDataRunner extends TestDataRunner {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* OrderTestDataRunner.
*/
@Component
@Profile("dev")
@Profile({"dev", "devcontainer"})
@Order(value = 6)
public class OrderTestDataRunner extends TestDataRunner {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.springframework.stereotype.Component;

@Component
@Profile("dev")
@Profile({"dev", "devcontainer"})
@Order(value = 1)
public class ProductTestDataRunner extends TestDataRunner {

Expand Down
12 changes: 8 additions & 4 deletions src/main/java/ch/wisv/events/utils/dev/data/TestDataRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ public void run(String... args) throws Exception {
JSONParser parser = new JSONParser();
JSONArray jsonArray = (JSONArray) parser.parse(new FileReader("src/main/resources/dev/data/" + this.jsonFileName));

for (Object object : jsonArray) {
JSONObject json = (JSONObject) object;

this.loop(json);
try {
for (Object object : jsonArray) {
JSONObject json = (JSONObject) object;

this.loop(json);
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.springframework.stereotype.Component;

@Component
@Profile("dev")
@Profile({"dev", "devcontainer"})
@Order(value = 5)
public class WebhookTestDataRunner extends TestDataRunner {

Expand Down

0 comments on commit 2728d29

Please sign in to comment.