-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: import Docker files from GHL_Backend commit 296c1b2
+ johnny990628/GHL_Backend@296c1b2 All files fork (copy) from: + https://github.com/johnny990628/GHL_Backend/tree/master/docker-compose
- Loading branch information
1 parent
a37eeaa
commit e32f325
Showing
5 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
MONGO_IMAGE_VERSION=5.0.8 | ||
# 5.0.8是20230318測試過最穩定運行的版本 | ||
|
||
# 以下設定3個Mongo Container映射到主機端的Port(內部均為27017) | ||
MONGO1_HOST_PORT=27117 | ||
MONGO2_HOST_PORT=27217 | ||
MONGO3_HOST_PORT=27317 | ||
|
||
# 以下設定6個Mongo Container映射到主機端的資料存放位置(預設採用此專案的相對路徑) | ||
MONGO1_DATA_STORAGE=./MongoData/mongo1_data | ||
MONGO1_CONFIG_STORAGE=./MongoData/mongo1_config | ||
MONGO2_DATA_STORAGE=./MongoData/mongo2_data | ||
MONGO2_CONFIG_STORAGE=./MongoData/mongo2_config | ||
MONGO3_DATA_STORAGE=./MongoData/mongo3_data | ||
MONGO3_CONFIG_STORAGE=./MongoData/mongo3_config |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
MongoData |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM ubuntu:22.04 | ||
MAINTAINER luckypig3400 | ||
|
||
# install app dependencies | ||
RUN apt update | ||
RUN apt install git -y | ||
RUN apt install curl -y | ||
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - | ||
RUN apt install nodejs -y | ||
RUN apt clean | ||
|
||
# Set Work Directory | ||
WORKDIR /home | ||
|
||
# install app | ||
RUN git clone https://github.com/johnny990628/GHL_Backend.git | ||
WORKDIR /home/GHL_Backend | ||
RUN npm install | ||
RUN npm install bcrypt | ||
# https://stackoverflow.com/questions/15809611/bcrypt-invalid-elf-header-when-running-node-app | ||
|
||
# final configuration | ||
EXPOSE 3080 | ||
CMD node server.js |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
services: | ||
# 啟動3個mongo container用以建置Replica Set | ||
KiwiRS-mongo1: | ||
hostname: KiwiRS-mongo1 | ||
image: mongo:${MONGO_IMAGE_VERSION} | ||
expose: | ||
- 27017 | ||
ports: | ||
- ${MONGO1_HOST_PORT}:27017 | ||
restart: always | ||
command: mongod --replSet my-mongo-set | ||
volumes: | ||
- ${MONGO1_DATA_STORAGE}:/data/db | ||
- ${MONGO1_CONFIG_STORAGE}:/data/configdb | ||
KiwiRS-mongo2: | ||
hostname: KiwiRS-mongo2 | ||
image: mongo:${MONGO_IMAGE_VERSION} | ||
expose: | ||
- 27017 | ||
ports: | ||
- ${MONGO2_HOST_PORT}:27017 | ||
restart: always | ||
command: mongod --replSet my-mongo-set | ||
volumes: | ||
- ${MONGO2_DATA_STORAGE}:/data/db | ||
- ${MONGO2_CONFIG_STORAGE}:/data/configdb | ||
KiwiRS-mongo3: | ||
hostname: KiwiRS-mongo3 | ||
image: mongo:${MONGO_IMAGE_VERSION} | ||
expose: | ||
- 27017 | ||
ports: | ||
- ${MONGO3_HOST_PORT}:27017 | ||
restart: always | ||
command: mongod --replSet my-mongo-set | ||
volumes: | ||
- ${MONGO3_DATA_STORAGE}:/data/db | ||
- ${MONGO3_CONFIG_STORAGE}:/data/configdb | ||
|
||
# 初始化Mongo Replica Server | ||
mongoinit: | ||
image: mongo:${MONGO_IMAGE_VERSION} | ||
# 這個Container只會執行一次 | ||
# 此Container可能會依據mongo1~3的啟動狀態受到一定程度的影響 | ||
# 啟動後記得查看此Container的Log,看到{ "ok" : 1 }才算成功! | ||
restart: "on-failure" | ||
depends_on: | ||
- KiwiRS-mongo1 | ||
- KiwiRS-mongo2 | ||
- KiwiRS-mongo3 | ||
command: > | ||
mongo --host KiwiRS-mongo1:27017 --eval 'config = { "_id" : "my-mongo-set", "members" : [ | ||
{ | ||
"_id" : 0, | ||
"host" : "KiwiRS-mongo1:27017", | ||
"priority" : 1 | ||
}, | ||
{ | ||
"_id" : 1, | ||
"host" : "KiwiRS-mongo2:27017", | ||
"priority" : 0.5 | ||
}, | ||
{ | ||
"_id" : 2, | ||
"host" : "KiwiRS-mongo3:27017", | ||
"priority" : 0.5 | ||
} | ||
] }; rs.initiate(config);' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
docker compose up -d |