-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiff.txt
157 lines (153 loc) · 4.48 KB
/
diff.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
diff --git a/.env.example b/.env.example
index da5ac87..a867b1d 100644
--- a/.env.example
+++ b/.env.example
@@ -1,5 +1,5 @@
-KOA_WORKSPACE=/mnt/ioinfinity/nodejs_tools/js-tutorial
-KOA_PROJECT_NAME=koa-tutorial
+JS_WORKSPACE=/mnt/ioinfinity/nodejs_tools/js-tutorials
+JS_PROJECT_NAME=hello-world-js
SSH_PUBLIC_KEYS_DIR=/home/ioinfinity/.ssh
KOA_PORT=3000
KOA_PORT_EXTERNAL=3000
diff --git a/docker-compose.local.yml b/docker-compose.local.yml
index ccc40e2..ef073e9 100644
--- a/docker-compose.local.yml
+++ b/docker-compose.local.yml
@@ -3,15 +3,15 @@ version: '3'
services:
mongodb:
image: mongo:latest
- container_name: my-mongodb
+ hostname: mangodb
restart: always
ports:
- "27017:27017"
volumes:
- ./mongodb-data:/data/db
environment:
- MONGO_INITDB_ROOT_USERNAME: koa
- MONGO_INITDB_ROOT_PASSWORD: koa
+ MONGO_INITDB_ROOT_USERNAME: mangodb
+ MONGO_INITDB_ROOT_PASSWORD: mangodb
db:
image: mysql:latest
restart: always
@@ -24,19 +24,42 @@ services:
- ./data:/var/lib/mysql
ports:
- "3306:3306"
- node-app:
+ js-dev:
build:
context: .
- dockerfile: ./dockerfiles/node.16.19.1.alpine.3.16.Dockerfile
+ dockerfile: ./dockerfiles/node.16.19.1.Dockerfile
+ command: "echo 'Hello';"
+ depends_on:
+ - db
+ - mongodb
+ - localstack
+ ports:
+ - ${KOA_PORT_EXTERNAL}:${KOA_PORT}
+ volumes:
+ - type: bind
+ source: ${JS_WORKSPACE}/${JS_PROJECT_NAME}
+ target: /code
+ - type: bind
+ source: ${SSH_PUBLIC_KEYS_DIR}
+ target: /root/.ssh
+ - type: bind
+ source: ${SSH_PUBLIC_KEYS_DIR}
+ target: /home/node/.ssh
+ - ${NODEJS_BUILD_FOLDER}:${NODEJS_BUILD_INTERNAL_FOLDER}
+ koa-app:
+ build:
+ context: .
+ dockerfile: ./dockerfiles/node.16.19.1.slim.Dockerfile
command: "node app.js api -p"
depends_on:
- db
- mongodb
+ - localstack
ports:
- ${KOA_PORT_EXTERNAL}:${KOA_PORT}
volumes:
- type: bind
- source: ${KOA_WORKSPACE}/${KOA_PROJECT_NAME}
+ source: ${JS_WORKSPACE}/${JS_PROJECT_NAME}
target: /code
- type: bind
source: ${SSH_PUBLIC_KEYS_DIR}
@@ -47,6 +70,7 @@ services:
- ${NODEJS_BUILD_FOLDER}:${NODEJS_BUILD_INTERNAL_FOLDER}
localstack:
image: localstack/localstack:latest
+ hostname: localstack
environment:
SERVICES: s3
DEBUG: 1
diff --git a/docker.sh b/docker.sh
index b58f3fd..c7fde8f 100755
--- a/docker.sh
+++ b/docker.sh
@@ -9,9 +9,13 @@ CMD_YARN="yarn"
CMD_JS_CONTAINER_SHELL="js-container-console"
CMD_JS_RUN="js-run"
+# Koa.js
+CMD_KOA_RUN="run-koa"
+
# Service
CMD_SERVICE_MANGODB="run-mangodb"
CMD_SERVICE_LOCALSTACK="run-localstack"
+CMD_SERVICE_LOCALSTACK_CONSOLE="console-localstack"
CMD_SERVICE_MYSQL="run-mysql"
# https://stackoverflow.com/questions/5474732/how-can-i-add-a-help-method-to-a-shell-script
@@ -27,8 +31,11 @@ Commands:
Run MangoDB server
\033[1m"$CMD_SERVICE_LOCALSTACK"\033[0m
Run Localstack server
+ \033[1m"$CMD_SERVICE_LOCALSTACK_CONSOLE"\033[0m
+ Localstack console
\033[1m"$CMD_SERVICE_MYSQL"\033[0m
Run MySQL server
+
NPM:
\033[1m"$CMD_NPM"\033[0m
Run npm command
@@ -37,8 +44,10 @@ Commands:
JS:
\033[1m"$CMD_JS_CONTAINER_SHELL"\033[0m
Console of JS App container
- \033[1m"$CMD_JS_RUN"\033[0m
- Run JS App container
+
+ Koa.js:
+ \033[1m"$CMD_KOA_RUN"\033[0m
+ Run Koa.js App container
"
seed=42
@@ -65,7 +74,7 @@ while getopts ':hs:' option; do
done
shift $((OPTIND - 1))
-PROJECT_NAME_JS='js-app'
+PROJECT_NAME_JS='js-dev'
DOCKER_FILE="docker-compose.local.yml"
CMD_DOCKER=" docker-compose -f $DOCKER_FILE "
CMD_DOCKER_JS_PROJ_RUN=" $CMD_DOCKER run $PROJECT_NAME_JS"
@@ -81,10 +90,14 @@ elif [ "$CMD_JS_CONTAINER_SHELL" == "$Command" ]; then
$CMD_DOCKER_JS_PROJ_RUN sh
elif [ "$CMD_JS_RUN" == "$Command" ]; then
$CMD_DOCKER up
+elif [ "$CMD_KOA_RUN" == "$Command" ]; then
+ $CMD_DOCKER up koa-app
elif [ "$CMD_SERVICE_MANGODB" == "$Command" ]; then
- $CMD_DOCKER up mangodb
+ $CMD_DOCKER up mongodb
elif [ "$CMD_SERVICE_LOCALSTACK" == "$Command" ]; then
$CMD_DOCKER up localstack
+elif [ "$CMD_SERVICE_LOCALSTACK_CONSOLE" == "$Command" ]; then
+ $CMD_DOCKER exec localstack sh
elif [ "$CMD_SERVICE_MYSQL" == "$Command" ]; then
$CMD_DOCKER up db
fi