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
10 changes: 10 additions & 0 deletions Dockerfile.backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM gradle:9.3.1-jdk21-alpine AS build
WORKDIR /app
COPY build.gradle.kts settings.gradle.kts gradle.properties ./
COPY src src
RUN echo "org.gradle.jvmargs=-Xmx1g" >> gradle.properties && gradle bootJar --no-daemon

FROM eclipse-temurin:21-jre
WORKDIR /app
COPY --from=build /app/build/libs/*.jar app.jar
ENTRYPOINT ["java", "-jar", "app.jar"]
11 changes: 11 additions & 0 deletions Dockerfile.frontend
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:22-alpine AS build
WORKDIR /app
COPY frontend/package*.json ./
RUN npm ci
COPY frontend .
RUN npm run build

FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 3000
15 changes: 3 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,15 @@ Key patterns:

## Prerequisites

- Java 21
- Docker
- Docker (at least 4 GB memory allocated to the Docker VM)

## Getting Started

Start the database:

```sh
docker compose up -d
```

Run the application:

```sh
./gradlew bootRun
docker compose up --build
```

The API is available at `http://localhost:8080`. Swagger UI is at `http://localhost:8080/docs/swagger-ui.html`.
The frontend is available at `http://localhost:3000`. The API is available at `http://localhost:8080`. Swagger UI is at `http://localhost:8080/docs/swagger-ui.html`.

## Running Tests

Expand Down
23 changes: 22 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,26 @@ services:
timeout: 10s
volumes:
- ./tmp/postgresql:/var/lib/postgresql/data

backend:
build:
context: .
dockerfile: Dockerfile.backend
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://database:5432/interview
SPRING_DATASOURCE_USERNAME: postgres
SPRING_DATASOURCE_PASSWORD: postgres
ports:
- "8080:8080"
depends_on:
database:
condition: service_healthy

frontend:
build:
context: .
dockerfile: Dockerfile.frontend
ports:
- "5432:5432"
- "3000:3000"
depends_on:
- backend
16 changes: 16 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
server {
listen 3000;

root /usr/share/nginx/html;
index index.html;

location /api {
proxy_pass http://backend:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}

location / {
try_files $uri $uri/ /index.html;
}
}