Skip to content

Commit

Permalink
Merge branch 'document/docker' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
thfla1105 committed Aug 5, 2022
2 parents d3e6b4c + 3a6b192 commit 6cbd681
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 19 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ out/
src/main/resources/application.properties
src/main/resources/application-oauth.properties
src/main/resources/application-cloud.properties
/settings/.env
src/main/resources/application-springboot.yml
/.env
.env
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM openjdk:17-jdk-slim

ADD ./build/libs/*.jar app.jar
ADD ./build/libs/backend_e-weather-0.0.1-SNAPSHOT.jar app.jar

CMD ["java", "-jar", "app.jar"]
CMD java -jar -Dspring.profiles.active=${active} app.jar
32 changes: 26 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,43 @@
version: "3"

services:
backend:
server1:
build:
context: .
dockerfile: Dockerfile
image: spring
container_name: server1
ports:
- 8080:8080
- 8082:8082
volumes:
- ./:/app
working_dir: /app
expose:
- 8080
env_file:
- ./settings/.env
- .env
environment:
active: prod1

server2:
build:
context: .
dockerfile: Dockerfile
image: spring
container_name: server2
ports:
- 8083:8083
volumes:
- ./:/app
working_dir: /app
env_file:
- .env
environment:
active: prod2


nginx:
build: ./nginx
ports:
- 80:80
depends_on:
- backend
- server1
- server2
4 changes: 2 additions & 2 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM nginx:latest

RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d
#RUN rm /etc/nginx/conf.d/default.conf
#COPY nginx.conf /etc/nginx/conf.d

CMD ["nginx", "-g", "daemon off;"]
4 changes: 2 additions & 2 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=STATIC:10m inactive=7d use_temp_path=off;

upstream api {
server backend:8080;
server spring:8080;
}

server {
listen 80 default_server;
listen 8080 default_server;
charset utf-8;

server_name _;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
//@EnableOpenApi
@EnableSwagger2
@Profile(value = "dev")
public class SpringFoxConfig {
public static final Contact DEFAULT_CONTACT =
new Contact(
Expand Down
13 changes: 8 additions & 5 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
application:
version: 1.0.0
title: eweather

cloud:
aws:
credentials:
Expand All @@ -10,6 +14,10 @@ cloud:
stack:
auto: 'false'
spring:
config:
import:
- optional:file:.env[.properties]
- classpath:/application-springboot.yml
jpa:
generate-ddl: 'false'
hibernate:
Expand All @@ -19,8 +27,6 @@ spring:
enable_lazy_load_no_trans: 'true'
format_sql: 'false'
database: mysql
profiles:
include: oauth
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
password: ${DATABASE_PASSWORD}
Expand Down Expand Up @@ -60,8 +66,5 @@ cors:
allowed-methods: ${CORS_ALLOWED_METHODS}
allowed-headers: ${CORS_ALLOWED_HEADERS}
max-age: ${CORS_MAX_AGE}
application:
version: 1.0.0
title: eweather
jwt:
secret: ${JWT_SECRET}

0 comments on commit 6cbd681

Please sign in to comment.