This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RedisHash("ClickCount") | |
@Builder | |
@Data | |
public class ClickCount implements Serializable { | |
@Id | |
private String id; | |
private long count; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-data-redis</artifactId> | |
<version>2.7.0</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.7" | |
services: | |
spring-app: | |
build: . | |
image: spring-app | |
ports: | |
- "4000:8080" | |
networks: | |
- shared-network | |
depends_on: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ping my-app | |
PING my-app (172.27.0.2): 56 data bytes | |
64 bytes from 172.27.0.2: seq=0 ttl=64 time=1.474 ms | |
64 bytes from 172.27.0.2: seq=1 ttl=64 time=0.283 ms | |
64 bytes from 172.27.0.2: seq=2 ttl=64 time=0.099 ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker network inspect my-bridge-network | |
[ | |
{ | |
"Name": "my-bridge-network", | |
"Id": "0ced7774d30c6be499dea707770a2a3783ef8336404d2b6bbb2e4d5743daebc9", | |
"Created": "2022-06-16T10:26:35.4088433Z", | |
"Scope": "local", | |
"Driver": "bridge", | |
"EnableIPv6": false, | |
"IPAM": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker container run -d --network my-bridge-network --name my-app alpine sleep 10m | |
04b6cda3bdac0a942a9850d8f955a01d48a24e097b57597c03bf19e9e67f8634 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker network create -d bridge my-bridge-network | |
0ced7774d30c6be499dea707770a2a3783ef8336404d2b6bbb2e4d5743daebc9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker compose up | |
[+] Running 1/1 | |
⠿ Container java-with-docker-backend-service-1 Created 0.1s | |
Attaching to java-with-docker-backend-service-1 | |
java-with-docker-backend-service-1 | | |
java-with-docker-backend-service-1 | . ____ _ __ _ _ | |
java-with-docker-backend-service-1 | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ | |
java-with-docker-backend-service-1 | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ | |
java-with-docker-backend-service-1 | \\/ ___)| |_)| | | | | || (_| | ) ) ) ) | |
java-with-docker-backend-service-1 | ' |____| .__|_| |_|_| |_\__, | / / / / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.7" | |
services: | |
backend-service: | |
build: . # where Dockerfile is located | |
ports: | |
- "4000:8080" # port mapping (hostPort:containerPort) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### BUILD ### | |
# use maven as base image | |
FROM maven:3.8.3-openjdk-16 AS build | |
# copy code to container directory (/home/app/src) | |
COPY /src /home/app/src | |
# copy pom to container directory (/home/app) | |
COPY pom.xml /home/app |