Skip to content

Commit a955412

Browse files
author
Justin Headley
committed
refactor: restoring changes that were removed accidentally
1 parent 89e4271 commit a955412

File tree

6 files changed

+55
-4
lines changed

6 files changed

+55
-4
lines changed

.env-docker

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ MONGODB_URI=mongodb://mongo:27017/appy
55
SERVER_HOST=localhost
66
SERVER_PORT=8080
77
CLIENT_URI=http://localhost:3000
8+
SERVER_HOST=localhost
9+
SERVER_PORT=8080
810
FACEBOOK_ID=1234
911
FACEBOOK_SECRET=abcd
1012
FACEBOOK_ACCESS_TOKEN=5678

Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ COPY ./package.json /backend
1111
# Install node dependencies
1212
RUN npm install
1313

14-
# Make port 8080 available to the world outside this container
15-
EXPOSE 8080
14+
ARG SERVER_PORT=8080
15+
# Make the server port available to the world outside this container
16+
EXPOSE ${SERVER_PORT}
1617

1718
# Run the start script when the container launches
1819
CMD ["npm", "run", "start"]

config/index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ const config = {
7171
projectName: constants.API_TITLE,
7272
port: {
7373
$filter: 'env',
74-
production: 8080,
75-
$default: 8080
74+
production: process.env.SERVER_PORT,
75+
$default: process.env.SERVER_PORT
7676
},
7777
S3BucketName: {
7878
$filter: 'env',
@@ -212,6 +212,11 @@ const config = {
212212
apiPath: path.join(__dirname, '/../server/api'),
213213
absolutePolicyPath: true,
214214
policyPath: path.join(__dirname, '/../server/policies'),
215+
swaggerHost: {
216+
$filter: 'env',
217+
production: process.env.SERVER_HOST,
218+
$default: `${process.env.SERVER_HOST}:${process.env.SERVER_PORT}`
219+
},
215220
authStrategy: {
216221
$filter: 'env',
217222
production: constants.AUTH_STRATEGIES.REFRESH,

docker-compose.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: "3.4"
2+
3+
volumes:
4+
mongo_data:
5+
name: appy_mongo_data
6+
7+
networks:
8+
backend:
9+
10+
services:
11+
12+
mongo:
13+
image: mongo:3.6.4
14+
ports:
15+
- 27018:27017
16+
volumes:
17+
- "mongo_data:/data/db"
18+
networks:
19+
- backend
20+
restart: always
21+
22+
api:
23+
build: ./
24+
ports:
25+
- "${SERVER_PORT}:${SERVER_PORT}"
26+
volumes:
27+
# Share the entire project except "node_modules". This prevents us from having to COPY the project files
28+
# in the Dockerfile, while still keeping separate node dependency files.
29+
- "./:/backend"
30+
- "/backend/node_modules"
31+
networks:
32+
- backend
33+
depends_on:
34+
- mongo
35+
env_file:
36+
- ./.env-docker

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
},
6161
"devDependencies": {
6262
"babel-eslint": "^8.2.3",
63+
"commander": "^2.20.0",
6364
"eslint": "^4.19.1",
6465
"eslint-config-prettier": "^2.9.0",
6566
"eslint-config-prettier-standard": "^2.0.0",

run_server.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
source .env-docker
4+
export SERVER_PORT=${SERVER_PORT}
5+
export COMPOSE_PROJECT_NAME=appy_backend
6+
docker-compose up --build

0 commit comments

Comments
 (0)