Skip to content

Commit

Permalink
Run with docker
Browse files Browse the repository at this point in the history
  • Loading branch information
GFWagnitz committed Jun 11, 2024
1 parent 7e47e28 commit 1afd27a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Base Image: Use the official OpenJDK image with a specific Java version (adjust as needed)
FROM maven:3.9.7-amazoncorretto-21 AS build

# Environment Variables
ENV APP_HOME=/app
ENV PORT=8080

# Set Working Directory for Build
WORKDIR $APP_HOME

# Copy Project Files
COPY . .

# Build the Application using Maven
RUN mvn package -DskipTests


# Runtime Image
FROM amazoncorretto:21-alpine-jdk

# Environment Variables
ENV APP_HOME=/app

# Create App Directory (If Needed)
WORKDIR $APP_HOME

# Copy the JAR from the Build Stage (target folder)
COPY --from=build $APP_HOME/target/app-1.0.jar app.jar

# Expose Port
EXPOSE $PORT

# Run the Application
ENTRYPOINT ["java","-jar","/app/app.jar"]
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
version: '3.7'
services:
app:
build: . # Build from the current directory (where Dockerfile is)
depends_on: # Ensures the DB is running before the app starts
- database
ports:
- "8080:8080" # Map your Spring Boot app's port
environment:
- MYSQL_HOST=database

database:
image: mysql:8.4
volumes:
Expand All @@ -12,6 +21,7 @@ services:
- MYSQL_DATABASE=aluno
- MYSQL_USER=aluno
- MYSQL_PASSWORD=aluno


volumes:
mysql:
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>br.ufes.inf.eventu</groupId>
<artifactId>app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.0</version>
<name>app</name>
<description>2024-Eventu for ProgWeb</description>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
import br.ufes.inf.eventu.app.services.interfaces.LocationService;
import jakarta.validation.Valid;

import java.time.LocalDateTime;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.HashSet;

import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -317,8 +318,9 @@ public String addAttractionTime(

try {
var time = new AttractionTime();
time.setStart(LocalDateTime.parse(attractionTimeModel.getStart()));
time.setFinish(LocalDateTime.parse(attractionTimeModel.getFinish()));
time.setDate(LocalDate.parse(attractionTimeModel.getDate()));
time.setStart(LocalTime.parse(attractionTimeModel.getStart()));
time.setFinish(LocalTime.parse(attractionTimeModel.getFinish()));
time.setLocation(locationDAO.findById(attractionTimeModel.getLocationId()).get());
time.setAttraction(attractionDAO.findById(attractionId).get());
attractionTimeService.save(time);
Expand Down

0 comments on commit 1afd27a

Please sign in to comment.