Skip to content

Commit c6f58e7

Browse files
committed
Apply docker to the project
Signed-off-by: Jeff Simons Decena <[email protected]>
1 parent 32ff24a commit c6f58e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+345
-246
lines changed

.DS_Store

6 KB
Binary file not shown.

.env.example

-18
This file was deleted.

.gitignore

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,16 +1 @@
1-
# Node modules
2-
node_modules
3-
package-lock.json
4-
5-
# Adonis directory for storing tmp files
6-
tmp
7-
8-
# Environment variables, never commit this file
9-
.env
10-
11-
# The development sqlite file
12-
database/development.sqlite
13-
14-
# VSCode & Webstorm history directories
15-
.history
16-
.idea
1+
db/*

Dockerfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM node:8.15-jessie
2+
3+
WORKDIR /app
4+
5+
COPY ./project .
6+
7+
RUN npm i -g @adonisjs/cli && \
8+
npm i --quiet --production && \
9+
npm i -g pm2
10+
11+
EXPOSE 3331
12+
13+
RUN pwd && ls -al
14+
15+
CMD ["pm2-runtime", "start", "server.js"]

README.md

+2-212
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MCCSPro - Municipalities, Cities, Countries, States and Provinces
22

3-
A NodeJS version of the [MCPro](https://github.com/jsdecena/mcpro) app.
3+
A NodeJS (AdonisJS Framework) version of the [MCPro](https://github.com/jsdecena/mcpro) app.
44
This app is so small and lightweight since the data being served is in `json` file
55

66
## Development Installation
@@ -11,214 +11,4 @@ This app is so small and lightweight since the data being served is in `json` fi
1111

1212
- Install packages `npm install`
1313

14-
- Serve the app `npm start`
15-
16-
## API ENDPOINTS
17-
18-
By default, this app run on port `3333`. You can change this in `.env` file.
19-
20-
```json
21-
# Countries
22-
- http://127.0.0.1:3333/countries
23-
24-
# Output
25-
[
26-
{
27-
"id": 1,
28-
"name": "AFGHANISTAN",
29-
"iso": "AF",
30-
"iso3": "AFG",
31-
"numcode": 4,
32-
"phonecode": 93,
33-
"status": 1,
34-
"created_at": "2018-11-16 15:20:34",
35-
"updated_at": "2018-11-16 15:20:34"
36-
},
37-
{
38-
"id": 2,
39-
"name": "ALBANIA",
40-
"iso": "AL",
41-
"iso3": "ALB",
42-
"numcode": 8,
43-
"phonecode": 355,
44-
"status": 1,
45-
"created_at": "2018-11-16 15:20:34",
46-
"updated_at": "2018-11-16 15:20:34"
47-
}
48-
...
49-
]
50-
```
51-
52-
```json
53-
# Country
54-
- http://127.0.0.1:3333/countries/:id
55-
- http://127.0.0.1:3333/countries/:iso3
56-
57-
# Output
58-
{
59-
"id": 226,
60-
"name": "UNITED STATES OF AMERICA",
61-
"iso": "US",
62-
"iso3": "USA",
63-
"numcode": 840,
64-
"phonecode": 1,
65-
"status": 1,
66-
"created_at": "2018-11-16 15:20:34",
67-
"updated_at": "2018-11-16 15:20:34"
68-
}
69-
```
70-
71-
```json
72-
# States
73-
- http://127.0.0.1:3333/countries/:id/states
74-
- http://127.0.0.1:3333/countries/:iso3/states
75-
76-
# Output
77-
[
78-
{
79-
"state": "Alaska",
80-
"state_code": "AK",
81-
"country_id": 226
82-
},
83-
{
84-
"state": "Alabama",
85-
"state_code": "AL",
86-
"country_id": 226
87-
}
88-
...
89-
]
90-
```
91-
92-
```json
93-
# State
94-
- http://127.0.0.1:3333/countries/:id/states/:state_code
95-
96-
# Output
97-
{
98-
"state": "Alaska",
99-
"state_code": "AK",
100-
"country_id": 226
101-
}
102-
```
103-
104-
```json
105-
# States
106-
- http://127.0.0.1:3333/states/:code/cities
107-
108-
# Output
109-
[
110-
{
111-
"name": "Adak",
112-
"state_code": "AK",
113-
"province_id": 0
114-
},
115-
{
116-
"name": "Akiachak",
117-
"state_code": "AK",
118-
"province_id": 0
119-
}
120-
...
121-
]
122-
```
123-
124-
```json
125-
# Country provinces (Philippines)
126-
- http://127.0.0.1:3333/countries/:id/provinces
127-
128-
# Output
129-
[
130-
{
131-
"id": 1,
132-
"name": "Abra",
133-
"country_id": 169,
134-
"status": 1,
135-
"created_at": "2018-11-16 15:20:34",
136-
"updated_at": "2018-11-16 15:20:34"
137-
},
138-
{
139-
"id": 2,
140-
"name": "Agusan del Norte",
141-
"country_id": 169,
142-
"status": 1,
143-
"created_at": "2018-11-16 15:20:34",
144-
"updated_at": "2018-11-16 15:20:34"
145-
}
146-
...
147-
]
148-
```
149-
150-
```json
151-
# Country province (Philippines)
152-
- http://127.0.0.1:3333/countries/:id/provinces/:id
153-
154-
# Output
155-
{
156-
"id": 1,
157-
"name": "Abra",
158-
"country_id": 169,
159-
"status": 1,
160-
"created_at": "2018-11-16 15:20:34",
161-
"updated_at": "2018-11-16 15:20:34"
162-
},
163-
```
164-
165-
```json
166-
# Provinces (Philippines)
167-
- http://127.0.0.1:3333/provinces
168-
169-
# Output
170-
[
171-
{
172-
"id": 1,
173-
"name": "Abra",
174-
"country_id": 169,
175-
"status": 1,
176-
"created_at": "2018-11-16 15:20:34",
177-
"updated_at": "2018-11-16 15:20:34"
178-
},
179-
{
180-
"id": 2,
181-
"name": "Agusan del Norte",
182-
"country_id": 169,
183-
"status": 1,
184-
"created_at": "2018-11-16 15:20:34",
185-
"updated_at": "2018-11-16 15:20:34"
186-
}
187-
...
188-
]
189-
```
190-
191-
```json
192-
# Province (Philippines)
193-
- http://127.0.0.1:3333/provinces/:id
194-
195-
# Output
196-
{
197-
"id": 1,
198-
"name": "Abra",
199-
"country_id": 169,
200-
"status": 1,
201-
"created_at": "2018-11-16 15:20:34",
202-
"updated_at": "2018-11-16 15:20:34"
203-
}
204-
```
205-
206-
```json
207-
# Cities
208-
- http://127.0.0.1:3333/provinces/:id/cities
209-
210-
# Output
211-
[
212-
{
213-
"name": "Bangued",
214-
"state_code": "",
215-
"province_id": 1
216-
},
217-
{
218-
"name": "Boliney",
219-
"state_code": "",
220-
"province_id": 1
221-
}
222-
...
223-
]
224-
```
14+
- Serve the app `npm start`

docker-compose.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
version: '3'
2+
services:
3+
server:
4+
container_name: server
5+
build: ./nginx
6+
ports:
7+
- "8001:8001"
8+
depends_on:
9+
- web
10+
networks:
11+
- app-ws
12+
stdin_open: true
13+
tty: true
14+
database:
15+
container_name: db
16+
image: postgres:11.4
17+
restart: always
18+
environment:
19+
POSTGRES_USER: postgres
20+
POSTGRES_PASSWORD: secret
21+
POSTGRES_DB: default
22+
TZ: "Asia/Manila"
23+
PGTZ: "Asia/Manila"
24+
ports:
25+
- "5432:5432"
26+
volumes:
27+
- ./db:/var/lib/postgresql/data
28+
networks:
29+
- app-ws
30+
web:
31+
container_name: app
32+
build: .
33+
environment:
34+
NODE_ENV: production
35+
TZ: "Asia/Manila"
36+
volumes:
37+
- ./project:/app
38+
- /app/node_modules
39+
- ./project/tmp:/app/tmp
40+
networks:
41+
- app-ws
42+
stdin_open: true
43+
tty: true
44+
depends_on:
45+
- database
46+
networks:
47+
app-ws:
48+
driver: bridge

nginx/Dockerfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM nginx:alpine
2+
3+
RUN rm /etc/nginx/conf.d/default.conf
4+
5+
COPY ./default.conf /etc/nginx/conf.d/default.conf
6+
7+
EXPOSE 8001

nginx/default.conf

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
upstream node_app {
2+
server web:3333;
3+
}
4+
5+
server {
6+
7+
listen 8001;
8+
9+
server_name _;
10+
11+
location / {
12+
proxy_pass http://node_app/;
13+
}
14+
}
File renamed without changes.

project/.env.example

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
HOST=127.0.0.1
2+
PORT=3333
3+
NODE_ENV=development
4+
APP_URL=http://${HOST}:${PORT}
5+
6+
CACHE_VIEWS=false
7+
8+
APP_KEY=AzoQGNIuAFjQU9y0YxrDROpgBpcmbvYM
9+
10+
DB_CONNECTION=pg
11+
DB_HOST=database
12+
DB_PORT=5432
13+
DB_USER=postgres
14+
DB_PASSWORD=secret
15+
DB_DATABASE=default
16+
17+
SESSION_DRIVER=cookie
18+
HASH_DRIVER=bcrypt

project/.gitignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Node modules
2+
node_modules
3+
package-lock.json
4+
5+
# Adonis directory for storing tmp files
6+
tmp
7+
8+
# Environment variables, never commit this file
9+
.env
10+
11+
# The development sqlite file
12+
database/development.sqlite
13+
14+
# VSCode & Webstorm history directories
15+
.history
16+
.idea

0 commit comments

Comments
 (0)