@ -281,6 +281,8 @@ systemctl restart docker
|
|||||||
- Allow port 3306 from `docker-security-group`
|
- Allow port 3306 from `docker-security-group`
|
||||||
- Attach SG to database in RDS `portal-db`
|
- Attach SG to database in RDS `portal-db`
|
||||||
|
|
||||||
|
#### 34.3 Build and Run Docker image in Docker EC2
|
||||||
|
|
||||||
|
- `mvn clean package docker:build docker:start`
|
||||||
|
|
||||||
|
|
||||||
@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
<mapstruct.version>1.4.2.Final</mapstruct.version>
|
<mapstruct.version>1.4.2.Final</mapstruct.version>
|
||||||
|
|
||||||
|
<docker.image.prefix>artarkatesoft</docker.image.prefix>
|
||||||
|
<docker.image.name>angular-${project.artifactId}</docker.image.name>
|
||||||
|
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -122,7 +125,7 @@
|
|||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
</exclude>
|
</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<executable>true</executable>
|
<!-- <executable>true</executable>-->
|
||||||
<finalName>support-portal</finalName>
|
<finalName>support-portal</finalName>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
@ -157,6 +160,44 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>io.fabric8</groupId>
|
||||||
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
|
<version>0.33.0</version>
|
||||||
|
<configuration>
|
||||||
|
<dockerHost>http://dockerapp.shyshkin.net:2375</dockerHost>
|
||||||
|
<verbose>true</verbose>
|
||||||
|
<containerNamePattern>%a</containerNamePattern>
|
||||||
|
<images>
|
||||||
|
<image>
|
||||||
|
<name>${docker.image.prefix}/${docker.image.name}</name>
|
||||||
|
<alias>${docker.image.name}</alias>
|
||||||
|
<build>
|
||||||
|
<assembly>
|
||||||
|
<descriptorRef>artifact</descriptorRef>
|
||||||
|
</assembly>
|
||||||
|
<dockerFile>Dockerfile</dockerFile>
|
||||||
|
<tags>
|
||||||
|
<tag>latest</tag>
|
||||||
|
<tag>${project.version}</tag>
|
||||||
|
</tags>
|
||||||
|
</build>
|
||||||
|
<run>
|
||||||
|
<ports>
|
||||||
|
<post>8080:8080</post>
|
||||||
|
</ports>
|
||||||
|
<env>
|
||||||
|
<SPRING_PROFILES_ACTIVE>aws-rds</SPRING_PROFILES_ACTIVE>
|
||||||
|
</env>
|
||||||
|
<restartPolicy>
|
||||||
|
<name>always</name>
|
||||||
|
</restartPolicy>
|
||||||
|
</run>
|
||||||
|
</image>
|
||||||
|
</images>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
25
support-portal-backend/src/main/docker/Dockerfile
Normal file
25
support-portal-backend/src/main/docker/Dockerfile
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
FROM openjdk:11-jre-slim as builder
|
||||||
|
WORKDIR application
|
||||||
|
ADD maven/${project.build.finalName}.jar ${project.build.finalName}.jar
|
||||||
|
RUN java -Djarmode=layertools -jar ${project.build.finalName}.jar extract
|
||||||
|
|
||||||
|
FROM openjdk:11-jre-slim
|
||||||
|
|
||||||
|
RUN apt update && apt install -y curl
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=5s --timeout=2s --start-period=10s --retries=5 \
|
||||||
|
CMD curl -f localhost:8080/actuator/health || false
|
||||||
|
|
||||||
|
LABEL PROJECT_NAME=${project.artifactId} \
|
||||||
|
PROJECT=${project.id}
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
ENV SERVER_PORT=8080
|
||||||
|
|
||||||
|
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", "-Djava.security.egd=file:/dev/./urandom", "org.springframework.boot.loader.JarLauncher"]
|
||||||
Reference in New Issue
Block a user