Oi Rodrigo, segue o DockerFile, docker-compose e o nginx.
docker-compose.yml
version: '3'
services:
mysql:
image: mysql:8.0.36
env_file: ./env/mysql.env
volumes:
- ./mysql-data:/var/lib/mysql
restart: unless-stopped
healthcheck:
test: mysqladmin ping -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD
interval: 5s
timeout: 5s
retries: 10
app:
image: eliascastrosousa/sgb:latest
env_file: ./env/app.env
restart: unless-stopped
depends_on:
mysql:
condition: service_healthy
nginx:
image: nginx:stable-alpine
ports:
- "80:80"
volumes:
- ./nginx:/etc/nginx/conf.d
restart: unless-stopped
depends_on:
- app
volumes:
mysql-data:
Dockerfile
FROM eclipse-temurin:21-jdk-alpine as builder
WORKDIR application
COPY mvnw .
COPY .mvn .mvn
COPY pom.xml .
COPY src src
RUN ./mvnw package -DskipTests
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract
FROM eclipse-temurin:21-jre-alpine
WORKDIR application
COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
nginx.conf
server {
listen 80;
server_name app;
location / {
proxy_pass http://app:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
obs: esse projeto "sgb" é muito similar ao da clinica vollmed, com crud de alunos, livros e emprestimo. usei a base do projeto para fazer esse para portfolio.