diff --git a/.gitea/workflows/build-and-deploy.yml b/.gitea/workflows/build-and-deploy.yml index 102ab41..49928d4 100644 --- a/.gitea/workflows/build-and-deploy.yml +++ b/.gitea/workflows/build-and-deploy.yml @@ -4,7 +4,7 @@ on: push: branches: - main - - main-debipogi + jobs: build-and-deploy: runs-on: ubuntu-latest @@ -19,18 +19,18 @@ jobs: mkdir -p ~/.ssh echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa - git clone --branch debipogi ssh://gitea@gitea.takiguchi.ovh:12960/Codiki/codiki-properties.git --config core.sshCommand='ssh -o StrictHostKeyChecking=no' + git clone ssh://gitea@gitea.takiguchi.ovh:12960/Codiki/codiki-properties.git --config core.sshCommand='ssh -o StrictHostKeyChecking=no' - name: 📄 Edit configuration run: | sed -i "s//$(cat ./codiki-properties/passwords/postgresql/codiki_user)/g" ./codiki-properties/application-prod.yml cp ./codiki-properties/application-prod.yml ./backend/codiki-launcher/src/main/resources/application.yml sed -i "s//$(cat ./codiki-properties/passwords/postgresql/codiki_admin)/g" ./docker-compose.yml - + - name: 🔨 Build backend docker image run: | sudo /usr/bin/docker build -t codiki-backend -f ./Dockerfile-backend . --no-cache - + - name: 📦 Extract backend docker image into archive run: | sudo /usr/bin/docker save codiki-backend:latest -o ./codiki-backend.tar @@ -42,14 +42,14 @@ jobs: - name: 📦 Extract frontend docker image into archive run: | sudo /usr/bin/docker save codiki-frontend:latest -o ./codiki-frontend.tar - + - name: 📤 Transfer artifacts to remote server env: - SSH_PRIVATE_KEY: ${{ secrets.D_PROD_SSH_PRIVATE_KEY }} - REMOTE_USER: ${{ secrets.D_PROD_REMOTE_USER }} - REMOTE_HOST: ${{ secrets.D_PROD_REMOTE_HOST }} - REMOTE_PORT: ${{ secrets.D_PROD_REMOTE_PORT }} - REMOTE_PATH: ${{ secrets.D_PROD_REMOTE_PATH }} + SSH_PRIVATE_KEY: ${{ secrets.PROD_SSH_PRIVATE_KEY }} + REMOTE_USER: ${{ secrets.PROD_REMOTE_USER }} + REMOTE_HOST: ${{ secrets.PROD_REMOTE_HOST }} + REMOTE_PORT: ${{ secrets.PROD_REMOTE_PORT }} + REMOTE_PATH: ${{ secrets.PROD_REMOTE_PATH }} run: | mkdir -p ~/.ssh echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa @@ -61,10 +61,10 @@ jobs: - name: 🚀 Launch application onto remote server env: SSH_PRIVATE_KEY: ${{ secrets.PROD_SSH_PRIVATE_KEY }} - REMOTE_USER: ${{ secrets.D_PROD_REMOTE_USER }} - REMOTE_HOST: ${{ secrets.D_PROD_REMOTE_HOST }} - REMOTE_PORT: ${{ secrets.D_PROD_REMOTE_PORT }} - REMOTE_PATH: ${{ secrets.D_PROD_REMOTE_PATH }} + REMOTE_USER: ${{ secrets.PROD_REMOTE_USER }} + REMOTE_HOST: ${{ secrets.PROD_REMOTE_HOST }} + REMOTE_PORT: ${{ secrets.PROD_REMOTE_PORT }} + REMOTE_PATH: ${{ secrets.PROD_REMOTE_PATH }} run: | ssh -o StrictHostKeyChecking=no $REMOTE_HOST -l $REMOTE_USER -p $REMOTE_PORT << EOC cd $REMOTE_PATH diff --git a/.gitignore b/.gitignore index 10f8e38..90e50cb 100644 --- a/.gitignore +++ b/.gitignore @@ -83,4 +83,14 @@ testem.log .DS_Store Thumbs.db -**/ci/bin/ \ No newline at end of file +**/ci/bin/ + + +# Linux start script should use lf +/gradlew text eol=lf +# These are Windows script files and should use crlf +*.bat text eol=crlf +# Binary files should be left untouched +*.jar binary + +**/.gradle \ No newline at end of file diff --git a/Dockerfile-backend b/Dockerfile-backend index 980f206..88ed7a5 100644 --- a/Dockerfile-backend +++ b/Dockerfile-backend @@ -1,15 +1,16 @@ -FROM maven:3.9.11-eclipse-temurin-21 AS builder +FROM gradle:9.0.0-jdk21 AS builder WORKDIR /app -COPY backend/pom.xml /app/ +COPY backend/gradlew /app/ +COPY backend/build.gradle.kts /app/ +COPY backend/settings.gradle.kts /app/ COPY backend/codiki-application /app/codiki-application COPY backend/codiki-domain /app/codiki-domain COPY backend/codiki-exposition /app/codiki-exposition COPY backend/codiki-infrastructure /app/codiki-infrastructure COPY backend/codiki-launcher /app/codiki-launcher WORKDIR /app -RUN mvn clean install -N -RUN mvn clean package +RUN gradle build jar FROM eclipse-temurin:21-jre-alpine AS final -COPY --from=builder /app/codiki-launcher/target/*.jar /app/codiki.jar +COPY --from=builder /app/codiki-launcher/build/libs/codiki-launcher.jar /app/codiki.jar CMD ["java", "-jar", "/app/codiki.jar"] \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 86d9401..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,84 +0,0 @@ -pipeline { - agent any - - stages { - stage('Configuration') { - steps { - dir('codiki-properties') { - git url:'https://gitea.takiguchi.ovh/Codiki/codiki-properties.git', branch: 'hexagonal-reforged', credentialsId: 'Jenkins-gitea' - } - script { - sh 'sed -i "s//$(cat ./codiki-properties/passwords/postgresql/codiki_user)/g" ./codiki-properties/application-prod.yml' - sh 'cp ./codiki-properties/application-prod.yml ./backend/codiki-launcher/src/main/resources/application-prod.yml' - sh 'sed -i "s//$(cat ./codiki-properties/passwords/postgresql/codiki_admin)/g" ./docker-compose.yml' - } - } - } - stage('Build') { - steps { - script { - sh """ - sudo /usr/bin/docker build -t codiki-backend -f ./Dockerfile-backend . --no-cache - sudo /usr/bin/docker build -t codiki-frontend -f ./Dockerfile-frontend . --no-cache - sudo /usr/bin/docker save codiki-backend:latest -o ./codiki-backend.tar - sudo /usr/bin/docker save codiki-frontend:latest -o ./codiki-frontend.tar - sudo chown jenkins:jenkins ./codiki-backend.tar - sudo chown jenkins:jenkins ./codiki-frontend.tar - chmod 644 ./codiki-backend.tar - chmod 644 ./codiki-frontend.tar - """ - } - } - } - stage('Deploy') { - steps { - sshPublisher( - publishers: [ - sshPublisherDesc( - configName: 'DebianServer [codiki]', - transfers: [ - sshTransfer( - cleanRemote: false, - excludes: '', - execCommand: '', - execTimeout: 120000, - flatten: false, - makeEmptyDirs: false, - noDefaultExcludes: false, - patternSeparator: '[, ]+', - remoteDirectory: '', - remoteDirectorySDF: false, - removePrefix: '', - sourceFiles: 'codiki-backend.tar,codiki-frontend.tar,docker-compose.yml' - ), - sshTransfer( - cleanRemote: false, - excludes: '', - execCommand: """ - cd /opt/codiki - sudo /usr/bin/docker load < /opt/codiki/codiki-backend.tar - sudo /usr/bin/docker load < /opt/codiki/codiki-frontend.tar - sudo /usr/bin/docker compose down - sudo /usr/bin/docker compose up --detach - """, - execTimeout: 120000, - flatten: false, - makeEmptyDirs: false, - noDefaultExcludes: false, - patternSeparator: '[, ]+', - remoteDirectory: '', - remoteDirectorySDF: false, - removePrefix: '', - sourceFiles: '' - ) - ], - usePromotionTimestamp: false, - useWorkspaceInPromotion: false, - verbose: true - ) - ] - ) - } - } - } -} diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts new file mode 100644 index 0000000..e1704b3 --- /dev/null +++ b/backend/build.gradle.kts @@ -0,0 +1,58 @@ +plugins { + kotlin("jvm") version "2.2.20" + kotlin("plugin.spring") version "2.2.20" + id("io.spring.dependency-management") version "1.1.7" +} + +group = "org.codiki" +version = "0.0.1-SNAPSHOT" + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } +} + +repositories { + mavenCentral() +} + +subprojects { + apply(plugin = "java") + apply(plugin = "org.jetbrains.kotlin.jvm") + + repositories { + mavenCentral() + } + + dependencies { + implementation(platform("org.springframework.boot:spring-boot-dependencies:3.5.5")) + compileOnly("org.projectlombok:lombok:1.18.40") + annotationProcessor("org.projectlombok:lombok:1.18.40") + testImplementation("org.assertj:assertj-core:3.27.4") + testImplementation("org.junit.jupiter:junit-jupiter-api") + testImplementation("org.junit.jupiter:junit-jupiter-params") + testImplementation("org.springframework.boot:spring-boot-starter-test") + testImplementation("org.junit.platform:junit-platform-launcher") + } + + tasks.withType { + useJUnitPlatform() + } +} + +dependencyManagement { + imports { + mavenBom("org.springframework.boot:spring-boot-dependencies:3.5.5") + } +} + +kotlin { + compilerOptions { + freeCompilerArgs.addAll("-Xjsr305=strict") + } +} + +tasks.withType { + useJUnitPlatform() +} \ No newline at end of file diff --git a/backend/codiki-application/build.gradle.kts b/backend/codiki-application/build.gradle.kts new file mode 100644 index 0000000..9435c50 --- /dev/null +++ b/backend/codiki-application/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + id("io.spring.dependency-management") version "1.1.7" +} + +dependencies { + implementation(project(":codiki-domain")) + implementation("org.springframework:spring-context") + implementation("org.springframework.boot:spring-boot-starter-security") + implementation("com.auth0:java-jwt:4.5.0") + implementation("org.apache.commons:commons-lang3") //:3.18.0 +} \ No newline at end of file diff --git a/backend/codiki-application/pom.xml b/backend/codiki-application/pom.xml deleted file mode 100644 index 8ee47ab..0000000 --- a/backend/codiki-application/pom.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - 4.0.0 - - org.codiki - codiki-parent - 0.0.1-SNAPSHOT - - - - codiki-application - - codiki-application - Demo project for Spring Boot - - jar - - - - org.codiki - codiki-domain - - - org.springframework - spring-context - - - org.springframework.boot - spring-boot-starter-security - - - com.auth0 - java-jwt - - - org.apache.commons - commons-lang3 - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-params - test - - - org.assertj - assertj-core - test - - - diff --git a/backend/codiki-application/src/test/java/org/codiki/application/publication/KeyGeneratorTest.java b/backend/codiki-application/src/test/java/org/codiki/application/publication/KeyGeneratorTest.java index b71863b..f38bc26 100644 --- a/backend/codiki-application/src/test/java/org/codiki/application/publication/KeyGeneratorTest.java +++ b/backend/codiki-application/src/test/java/org/codiki/application/publication/KeyGeneratorTest.java @@ -27,7 +27,4 @@ class KeyGeneratorTest { assertThat(validationRegex.matcher(result).matches()).isTrue(); }); } - - - } diff --git a/backend/codiki-domain/build.gradle.kts b/backend/codiki-domain/build.gradle.kts new file mode 100644 index 0000000..e69de29 diff --git a/backend/codiki-domain/pom.xml b/backend/codiki-domain/pom.xml deleted file mode 100644 index d881081..0000000 --- a/backend/codiki-domain/pom.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - 4.0.0 - - org.codiki - codiki-parent - 0.0.1-SNAPSHOT - - - - codiki-domain - - codiki-domain - Demo project for Spring Boot - - - - org.apache.maven.plugins - maven-compiler-plugin - - 16 - 16 - - - - - - jar - diff --git a/backend/codiki-exposition/build.gradle.kts b/backend/codiki-exposition/build.gradle.kts new file mode 100644 index 0000000..99e0c2b --- /dev/null +++ b/backend/codiki-exposition/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + id("io.spring.dependency-management") version "1.1.7" +} + +dependencies { + implementation(project(":codiki-application")) + implementation(project(":codiki-domain")) + implementation("org.springframework.boot:spring-boot-starter-web") + implementation("org.springframework.boot:spring-boot-starter-security") + implementation("org.apache.tika:tika-core:3.2.3") +} \ No newline at end of file diff --git a/backend/codiki-exposition/pom.xml b/backend/codiki-exposition/pom.xml deleted file mode 100644 index 1c195df..0000000 --- a/backend/codiki-exposition/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - 4.0.0 - - org.codiki - codiki-parent - 0.0.1-SNAPSHOT - - - - codiki-exposition - - codiki-exposition - Demo project for Spring Boot - - jar - - - - org.codiki - codiki-application - - - org.springframework.boot - spring-boot-starter-web - - - org.projectlombok - lombok - - - org.apache.tika - tika-core - - - diff --git a/backend/codiki-exposition/src/main/java/org/codiki/exposition/configuration/security/SecurityConfiguration.java b/backend/codiki-exposition/src/main/java/org/codiki/exposition/configuration/security/SecurityConfiguration.java index 74d6d27..ef03e88 100644 --- a/backend/codiki-exposition/src/main/java/org/codiki/exposition/configuration/security/SecurityConfiguration.java +++ b/backend/codiki-exposition/src/main/java/org/codiki/exposition/configuration/security/SecurityConfiguration.java @@ -29,7 +29,7 @@ public class SecurityConfiguration { public SecurityFilterChain securityFilterChain( HttpSecurity httpSecurity, JwtAuthenticationFilter jwtAuthenticationFilter - ) { + ) throws Exception { httpSecurity .csrf(AbstractHttpConfigurer::disable) .httpBasic(Customizer.withDefaults()) diff --git a/backend/codiki-exposition/src/main/java/org/codiki/exposition/user/UserController.java b/backend/codiki-exposition/src/main/java/org/codiki/exposition/user/UserController.java index 87a7b49..3c3dd7f 100644 --- a/backend/codiki-exposition/src/main/java/org/codiki/exposition/user/UserController.java +++ b/backend/codiki-exposition/src/main/java/org/codiki/exposition/user/UserController.java @@ -12,6 +12,8 @@ import org.codiki.exposition.user.model.LoginRequest; import org.codiki.exposition.user.model.LoginResponse; import org.codiki.exposition.user.model.RefreshTokenRequest; import org.codiki.exposition.user.model.SignInRequestDto; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -23,9 +25,14 @@ import org.springframework.web.bind.annotation.RestController; @RequestMapping("/api/users") public class UserController { private final UserUseCases userUseCases; + private final boolean signupEnabled; - public UserController(UserUseCases userUseCases) { + public UserController( + UserUseCases userUseCases, + @Value("${application.signup.enabled:true}") boolean signupEnabled + ) { this.userUseCases = userUseCases; + this.signupEnabled = signupEnabled; } @PostMapping("/login") @@ -49,7 +56,12 @@ public class UserController { @PostMapping @ResponseStatus(CREATED) - public void signIn(@RequestBody SignInRequestDto request) { - userUseCases.createUser(request.pseudo(), request.email(), request.password()); + public ResponseEntity signIn(@RequestBody SignInRequestDto request) { + if (signupEnabled) { + userUseCases.createUser(request.pseudo(), request.email(), request.password()); + return ResponseEntity.status(CREATED).build(); + } else { + return ResponseEntity.notFound().build(); + } } } diff --git a/backend/codiki-infrastructure/build.gradle.kts b/backend/codiki-infrastructure/build.gradle.kts new file mode 100644 index 0000000..8bfeab6 --- /dev/null +++ b/backend/codiki-infrastructure/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + id("io.spring.dependency-management") version "1.1.7" +} + +dependencies { + implementation(project(":codiki-application")) + implementation(project(":codiki-domain")) + implementation("org.springframework:spring-context") + implementation("org.springframework.boot:spring-boot-starter-data-jpa") + implementation("org.postgresql:postgresql:42.7.5") +} \ No newline at end of file diff --git a/backend/codiki-infrastructure/pom.xml b/backend/codiki-infrastructure/pom.xml deleted file mode 100644 index 23883b2..0000000 --- a/backend/codiki-infrastructure/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - 4.0.0 - - org.codiki - codiki-parent - 0.0.1-SNAPSHOT - - - - codiki-infrastructure - - codiki-infrastructure - Demo project for Spring Boot - - jar - - - - org.codiki - codiki-domain - - - org.springframework - spring-context - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.projectlombok - lombok - - - org.postgresql - postgresql - - - org.apache.commons - commons-lang3 - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-params - test - - - org.assertj - assertj-core - test - - - diff --git a/backend/codiki-infrastructure/src/main/java/org/codiki/infrastructure/configuration/JpaConfiguration.java b/backend/codiki-infrastructure/src/main/java/org/codiki/infrastructure/configuration/JpaConfiguration.java index 9025bf6..d75d941 100644 --- a/backend/codiki-infrastructure/src/main/java/org/codiki/infrastructure/configuration/JpaConfiguration.java +++ b/backend/codiki-infrastructure/src/main/java/org/codiki/infrastructure/configuration/JpaConfiguration.java @@ -1,6 +1,6 @@ package org.codiki.infrastructure.configuration; -import org.springframework.boot.persistence.autoconfigure.EntityScan; +import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.context.annotation.Configuration; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; diff --git a/backend/codiki-launcher/build.gradle.kts b/backend/codiki-launcher/build.gradle.kts new file mode 100644 index 0000000..7c0ef25 --- /dev/null +++ b/backend/codiki-launcher/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + id("org.springframework.boot") version "3.5.5" + id("io.spring.dependency-management") version "1.1.7" +} + +dependencies { + implementation(project(":codiki-domain")) + implementation(project(":codiki-application")) + implementation(project(":codiki-infrastructure")) + implementation(project(":codiki-exposition")) + implementation("org.springframework.boot:spring-boot-starter-web") + implementation("org.springframework.boot:spring-boot-devtools") +} + +springBoot { + mainClass = "org.codiki.launcher.ApplicationLauncher" +} diff --git a/backend/codiki-launcher/pom.xml b/backend/codiki-launcher/pom.xml deleted file mode 100644 index 413acc3..0000000 --- a/backend/codiki-launcher/pom.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - 4.0.0 - - org.codiki - codiki-parent - 0.0.1-SNAPSHOT - - - - codiki-launcher - - codiki-launcher - Demo project for Spring Boot - - jar - - - - org.codiki - codiki-exposition - - - org.codiki - codiki-application - - - org.codiki - codiki-domain - - - org.codiki - codiki-infrastructure - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - - - - - diff --git a/backend/codiki-launcher/src/main/resources/application-docker.yml b/backend/codiki-launcher/src/main/resources/application-docker.yml new file mode 100644 index 0000000..70c9f6e --- /dev/null +++ b/backend/codiki-launcher/src/main/resources/application-docker.yml @@ -0,0 +1,33 @@ +application: + security: + jwt: + secretKey: "secret-key" + expirationDelayInMinutes: 30 + refreshToken: + expirationDelayInDays: 7 + pictures: + path: /opt/codiki/pictures/ + temp-path: /opt/codiki/pictures/temp/ + +logging: + level: + org.springframework.security: DEBUG + +server: + http2: + enabled: true + error: + whitelabel: + enabled: false # Disable html error responses. + include-stacktrace: never + +spring: + datasource: + driverClassName: org.postgresql.Driver + url: jdbc:postgresql://codiki-database:5432/codiki_db + username: codiki_user + password: password + servlet: + multipart: + max-file-size: 150MB + max-request-size: 151MB diff --git a/backend/codiki-launcher/src/main/resources/application-local.yml b/backend/codiki-launcher/src/main/resources/application-local.yml index 38d0567..b382088 100644 --- a/backend/codiki-launcher/src/main/resources/application-local.yml +++ b/backend/codiki-launcher/src/main/resources/application-local.yml @@ -1,7 +1,7 @@ application: pictures: - path: /Users/fthierry/Documents/Developpement/codiki-hexagonal/backend/pictures-folder - temp-path: /Users/fthierry/Documents/Developpement/codiki-hexagonal/backend/pictures-folder/temp + path: /Users/florian/Documents/Developpement/codiki-hexagonal/backend/pictures-folder/ + temp-path : /Users/florian/Documents/Developpement/codiki-hexagonal/backend/pictures-folder/temp/ logging: level: diff --git a/backend/codiki-launcher/src/main/resources/application.yml b/backend/codiki-launcher/src/main/resources/application.yml index 78889d9..196381a 100644 --- a/backend/codiki-launcher/src/main/resources/application.yml +++ b/backend/codiki-launcher/src/main/resources/application.yml @@ -1,4 +1,6 @@ application: + signup: + enabled: true security: jwt: secretKey: "secret-key" diff --git a/backend/gradle/wrapper/gradle-wrapper.jar b/backend/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..61285a6 Binary files /dev/null and b/backend/gradle/wrapper/gradle-wrapper.jar differ diff --git a/backend/gradle/wrapper/gradle-wrapper.properties b/backend/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..19a6bde --- /dev/null +++ b/backend/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.0-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/backend/gradlew b/backend/gradlew new file mode 100755 index 0000000..adff685 --- /dev/null +++ b/backend/gradlew @@ -0,0 +1,248 @@ +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/backend/gradlew.bat b/backend/gradlew.bat new file mode 100644 index 0000000..c4bdd3a --- /dev/null +++ b/backend/gradlew.bat @@ -0,0 +1,93 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/backend/pom.xml b/backend/pom.xml deleted file mode 100644 index 35ae542..0000000 --- a/backend/pom.xml +++ /dev/null @@ -1,98 +0,0 @@ - - - 4.0.0 - - org.codiki - codiki-parent - 0.0.1-SNAPSHOT - - pom - - codiki - - - 21 - 21 - 21 - 6.1.0 - 4.5.1 - 42.7.10 - 3.3.0 - 3.20.0 - - - - codiki-domain - codiki-application - codiki-infrastructure - codiki-exposition - codiki-launcher - - - - - - org.springframework.boot - spring-boot-dependencies - 4.0.5 - pom - import - - - org.codiki - codiki-exposition - ${project.version} - - - org.codiki - codiki-application - ${project.version} - - - org.codiki - codiki-domain - ${project.version} - - - org.codiki - codiki-infrastructure - ${project.version} - - - jakarta.servlet - jakarta.servlet-api - ${jakarta.servlet-api.version} - - - com.auth0 - java-jwt - ${java-jwt.version} - - - org.postgresql - postgresql - ${postgresql.version} - - - org.apache.tika - tika-core - ${tika-core.version} - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/backend/settings.gradle.kts b/backend/settings.gradle.kts new file mode 100644 index 0000000..2a2fa37 --- /dev/null +++ b/backend/settings.gradle.kts @@ -0,0 +1,2 @@ +rootProject.name = "codiki-backend" +include("codiki-domain", "codiki-application", "codiki-exposition", "codiki-infrastructure", "codiki-launcher") diff --git a/docker-compose.yml b/docker-compose.yml index 90972fa..c79c19f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,6 +20,7 @@ services: container_name: "codiki-backend" environment: - "SPRING_PROFILES_ACTIVE=prod" + - "APPLICATION_SIGNUP_ENABLED=false" ports: - "50011:8080" volumes: diff --git a/frontend/conf/nginx.conf b/frontend/conf/nginx.conf index 9e37b94..d986ada 100644 --- a/frontend/conf/nginx.conf +++ b/frontend/conf/nginx.conf @@ -20,7 +20,7 @@ http { server_name codiki.org; root /usr/share/nginx/html; - # Fallback to default language if no preference defined by browser + # Fallback to default language if no preference defined by browser if ($accept_language ~ "^$") { set $accept_language "fr"; } @@ -44,11 +44,11 @@ http { } location ~ ^/api { - proxy_pass http://192.168.1.154:50011; + proxy_pass http://codiki-backend:8080; proxy_set_header Host $host:$server_port; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } -} \ No newline at end of file +}