Skip to content

Commit

Permalink
docker support added
Browse files Browse the repository at this point in the history
  • Loading branch information
DsTyM committed Jan 13, 2020
1 parent 73e9a92 commit 0c569b1
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 68 deletions.
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#### Stage 1: Build the application
FROM openjdk:13.0.1 as build

# Set the current working directory inside the image
WORKDIR /app

# Copy maven executable to the image
COPY mvnw .
COPY .mvn .mvn

# Copy the pom.xml file
COPY pom.xml .

# Build all the dependencies in preparation to go offline.
# This is a separate step so the dependencies will be cached unless
# the pom.xml file has changed.
RUN chmod +x ./mvnw
RUN ./mvnw dependency:go-offline -B

# Copy the project source
COPY src src

# Package the application
RUN ./mvnw package -DskipTests
ENTRYPOINT ["java", "-jar", "target/pharmacies-on-duty-attica.jar"]
48 changes: 48 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Docker Compose file Reference (https://docs.docker.com/compose/compose-file/)

version: '3.7'

# Define services
services:
# App backend service
app-server:
# Configuration for building the docker image for the backend service
build:
context: . # Use an image built from the specified dockerfile in the `polling-app-server` directory.
dockerfile: Dockerfile
ports:
- "8080:8080" # Forward the exposed port 8080 on the container to port 8080 on the host machine
restart: always
depends_on:
- db # This service depends on mysql. Start that first.
environment: # Pass environment variables to the service
SPRING_DATASOURCE_URL: jdbc:mysql://db:3306/pharmacies?useSSL=false&serverTimezone=UTC&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&allowPublicKeyRetrieval=true
SPRING_DATASOURCE_USERNAME: developer
SPRING_DATASOURCE_PASSWORD: developer
networks: # Networks to join (Services on the same network can communicate with each other using their name)
- backend

# Database Service (Mysql)
db:
image: mysql:8.0.18
ports:
- "3306:3306"
restart: always
environment:
MYSQL_DATABASE: pharmacies
MYSQL_USER: developer
MYSQL_PASSWORD: developer
MYSQL_ROOT_PASSWORD: root
volumes:
- ./mysql-dump:/docker-entrypoint-initdb.d
- db-data:/var/lib/mysql
networks:
- backend

# Volumes
volumes:
db-data:

# Networks to be created to facilitate communication between containers
networks:
backend:
65 changes: 0 additions & 65 deletions docker_with_spring_notes.txt

This file was deleted.

File renamed without changes.
10 changes: 7 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
</parent>
<groupId>com.dstym</groupId>
<artifactId>pharmacies-on-duty-attica</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.0-SNAPSHOT</version>
<name>pharmacies-on-duty-attica</name>
<description>Demo project for Spring Boot</description>
<description>Pharmacies on Duty Attica Spring Boot Web App</description>

<properties>
<java.version>13</java.version>
Expand All @@ -23,6 +23,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand All @@ -34,6 +35,7 @@
<scope>runtime</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
Expand Down Expand Up @@ -72,8 +74,10 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>pharmacies-on-duty-attica</finalName>
</configuration>
</plugin>
</plugins>
</build>

</project>

0 comments on commit 0c569b1

Please sign in to comment.