Skip to content

Conversation

@MariyaMahrouqi
Copy link

1. Created Dickerfile with this configuration:
FROM maven:3.8.1-openjdk-17 AS build
WORKDIR /app
COPY . .
RUN mvn clean package -DskipTests

FROM openjdk:17-jdk-slim
WORKDIR /app
COPY --from=build /app/target/rihal-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT ["java", "-jar", "app.jar"]

2. Created docker-compose.yml with this configuration:
version: '3.8'
services:
mysql:
image: mysql:9.0.0
container_name: mysql-cont
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: usersystem
MYSQL_PASSWORD: root
ports:
- "3307:3307"
volumes:
- mysql_data:/var/lib/mysql

app:
build: .
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3307/usersystem?useSSL=false&serverTimezone=UTC&createDatabaseIfNotExist=true&allowPublicKeyRetrieval=true
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_PASSWORD: root
SPRING_JPA_HIBERNATE_DDL_AUTO: update
SPRING_JPA_SHOW_SQL: "true"
ports:
- "8080:8080"
depends_on:
- mysql
networks:
- app-network

volumes:
mysql_data:

networks:
app-network:

  1. I run : docker-compose up --build

Copy link
Owner

@CodelineAtyab CodelineAtyab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of files showing changes, Usually the review should have just a Dockerfile, docker-compose.yaml and a template for .env if applicable

environment:
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3307/usersystem?useSSL=false&serverTimezone=UTC&createDatabaseIfNotExist=true&allowPublicKeyRetrieval=true
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_PASSWORD: root
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should never push the password on GitHub.
Using the .env file can help solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants