adding database support
This commit is contained in:
		| @ -47,5 +47,5 @@ jobs: | |||||||
|         scp -o "StrictHostKeyChecking=no" -o "LogLevel=ERROR" -i key -r * ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:api/ |         scp -o "StrictHostKeyChecking=no" -o "LogLevel=ERROR" -i key -r * ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:api/ | ||||||
|     - name: restarting the backend  |     - name: restarting the backend  | ||||||
|       run: | |       run: | | ||||||
|         ssh -o "StrictHostKeyChecking=no" -o "LogLevel=ERROR" -i key ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd api/backend && docker-compose down && docker-compose up --force-recreate --build -d && docker image prune -f" |         ssh -o "StrictHostKeyChecking=no" -o "LogLevel=ERROR" -i key ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd api/backend && docker build -t clyde/backend . && docker run --rm -d -p 4000:8080 clyde/backend && docker image prune -f" | ||||||
|     - run: echo "The backend has been deployed. running at https://clyde.herisson.ovh/api" |     - run: echo "The backend has been deployed. running at https://clyde.herisson.ovh/api" | ||||||
|  | |||||||
| @ -16,17 +16,17 @@ repositories { | |||||||
| } | } | ||||||
|  |  | ||||||
| dependencies { | dependencies { | ||||||
| 	// implementation("org.springframework.boot:spring-boot-starter-jdbc") | 	implementation("org.springframework.boot:spring-boot-starter-jdbc") | ||||||
| 	implementation("org.springframework.boot:spring-boot-starter-mail") | 	implementation("org.springframework.boot:spring-boot-starter-mail") | ||||||
| 	implementation("org.springframework.boot:spring-boot-starter-web") | 	implementation("org.springframework.boot:spring-boot-starter-web") | ||||||
| 	// implementation("org.springframework.session:spring-session-jdbc") | 	implementation("org.springframework.session:spring-session-jdbc") | ||||||
| 	developmentOnly("org.springframework.boot:spring-boot-devtools") | 	developmentOnly("org.springframework.boot:spring-boot-devtools") | ||||||
| 	// developmentOnly("org.springframework.boot:spring-boot-docker-compose") | 	developmentOnly("org.springframework.boot:spring-boot-docker-compose") | ||||||
| 	runtimeOnly("org.postgresql:postgresql") | 	runtimeOnly("org.postgresql:postgresql") | ||||||
| 	testImplementation("org.springframework.boot:spring-boot-starter-test") | 	testImplementation("org.springframework.boot:spring-boot-starter-test") | ||||||
| 	// testImplementation("org.springframework.boot:spring-boot-testcontainers") | 	testImplementation("org.springframework.boot:spring-boot-testcontainers") | ||||||
| 	// testImplementation("org.testcontainers:junit-jupiter") | 	testImplementation("org.testcontainers:junit-jupiter") | ||||||
| 	// testImplementation("org.testcontainers:postgresql") | 	testImplementation("org.testcontainers:postgresql") | ||||||
| } | } | ||||||
|  |  | ||||||
| tasks.register("run") { | tasks.register("run") { | ||||||
|  | |||||||
| @ -1,13 +1,9 @@ | |||||||
| services: | services: | ||||||
|   backend: |  | ||||||
|     build: . |  | ||||||
|     ports: |  | ||||||
|       - 4000:8080 |  | ||||||
|   postgres: |   postgres: | ||||||
|     image: 'postgres:latest' |     image: 'postgres:latest' | ||||||
|     environment: |     environment: | ||||||
|       - 'POSTGRES_DB=mydatabase' |       - 'POSTGRES_DB=clyde' | ||||||
|       - 'POSTGRES_PASSWORD=secret' |       - 'POSTGRES_USER=devel' | ||||||
|       - 'POSTGRES_USER=myuser' |       - 'POSTGRES_PASSWORD=devel' | ||||||
|     ports: |     ports: | ||||||
|       - '5432' |       - '5432:5432' | ||||||
|  | |||||||
							
								
								
									
										23
									
								
								backend/src/main/java/ovh/herisson/Clyde/JdbcConfig.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								backend/src/main/java/ovh/herisson/Clyde/JdbcConfig.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | |||||||
|  | package ovh.herisson.Clyde; | ||||||
|  |  | ||||||
|  | import javax.sql.DataSource; | ||||||
|  |  | ||||||
|  | import org.springframework.context.annotation.Bean; | ||||||
|  | import org.springframework.context.annotation.Configuration; | ||||||
|  | import org.springframework.jdbc.datasource.DriverManagerDataSource; | ||||||
|  |  | ||||||
|  | @Configuration | ||||||
|  | public class JdbcConfig { | ||||||
|  |  | ||||||
|  | 	@Bean | ||||||
|  | 	public DataSource psqlSource(){ | ||||||
|  | 		DriverManagerDataSource source = new DriverManagerDataSource(); | ||||||
|  | 		source.setDriverClassName("org.postgresql.Driver"); | ||||||
|  | 		source.setUrl("jdbc:postgresql://localhost:5432/clyde"); | ||||||
|  | 		source.setUsername("devel"); | ||||||
|  | 		source.setPassword("devel"); | ||||||
|  |  | ||||||
|  | 		return source; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user