Added docker compose
This commit is contained in:
parent
abb89dbc6e
commit
c3dfab19ea
18
Dockerfile
Normal file
18
Dockerfile
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
FROM maven:4.0.0-rc-4-eclipse-temurin-21-alpine AS build
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# separate dependency stage to reduce build time when dependencies are unchanged
|
||||||
|
COPY pom.xml .
|
||||||
|
RUN mvn dependency:go-offline -B
|
||||||
|
|
||||||
|
COPY src ./src
|
||||||
|
# issues when not skipping, idk why
|
||||||
|
RUN mvn clean package -DskipTests
|
||||||
|
|
||||||
|
# openjdk is now deprecated over temurin
|
||||||
|
FROM eclipse-temurin:21-jre-alpine
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=build /app/target/*.jar app.jar
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
ENTRYPOINT ["java", "-jar", "app.jar"]
|
||||||
45
docker-compose.yml
Normal file
45
docker-compose.yml
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:18-alpine
|
||||||
|
container_name: itse-b08-database
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: pw_demo
|
||||||
|
POSTGRES_USER: pw_demo
|
||||||
|
POSTGRES_PASSWORD: pw_demo
|
||||||
|
ports:
|
||||||
|
- "5432:5432"
|
||||||
|
volumes:
|
||||||
|
- postgres_data:/var/lib/postgresql/data
|
||||||
|
- ./init-scripts:/docker-entrypoint-initdb.d
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U myuser -d myappdb"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
networks:
|
||||||
|
- app-network
|
||||||
|
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
container_name: itse-b08-spring
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
environment:
|
||||||
|
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/pw_demo
|
||||||
|
SPRING_DATASOURCE_USERNAME: pw_demo
|
||||||
|
SPRING_DATASOURCE_PASSWORD: pw_demo
|
||||||
|
SPRING_JPA_HIBERNATE_DDL_AUTO: update
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
|
networks:
|
||||||
|
- app-network
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
postgres_data:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
app-network:
|
||||||
|
driver: bridge
|
||||||
13
init-scripts/init.sql
Normal file
13
init-scripts/init.sql
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS users (
|
||||||
|
username VARCHAR(50) NOT NULL PRIMARY KEY,
|
||||||
|
password VARCHAR(500) NOT NULL,
|
||||||
|
enabled BOOLEAN NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS authorities (
|
||||||
|
username VARCHAR(50) NOT NULL,
|
||||||
|
authority VARCHAR(50) NOT NULL,
|
||||||
|
CONSTRAINT fk_authorities_users FOREIGN KEY (username) REFERENCES users(username)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX IF NOT EXISTS ix_auth_username ON authorities (username, authority);
|
||||||
Loading…
x
Reference in New Issue
Block a user