-
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.
add working docker configuration for dev, test, and production environments. change FRONT_URL to CLIENT_URL. fix errors caused by CLIENT_URL BREAKING CHANGE: yarn start does not build before starting. Use yarn start:build if you want to build before starting. FRONT_URL has been replaced with CLIENT_URL as it is more descriptive Running yarn docker:dev results in error while composing node-app saisilinus#28
- Loading branch information
1 parent
ceb2c32
commit f762ea8
Showing
14 changed files
with
85 additions
and
51 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 |
---|---|---|
|
@@ -23,7 +23,9 @@ SMTP_PORT=587 | |
SMTP_USERNAME=email-server-username | ||
SMTP_PASSWORD=email-server-password | ||
EMAIL_FROM=[email protected] | ||
FRONT_URL=http://localhost:5000 | ||
|
||
# Cookie configs | ||
COOKIE_SECRET=thisisasamplesecret | ||
|
||
# URL of client application | ||
CLIENT_URL=http://localhost:5000 |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
bin | ||
data |
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
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 |
---|---|---|
|
@@ -11,5 +11,8 @@ yarn-error.log | |
# Code coverage | ||
coverage | ||
|
||
# bunlde folder | ||
dist | ||
# build folder | ||
dist | ||
|
||
# docker volume | ||
data |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
node_modules | ||
coverage | ||
|
||
data |
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 |
---|---|---|
@@ -1,15 +1,26 @@ | ||
FROM node:alpine | ||
# development stage | ||
FROM node:14-alpine as base | ||
|
||
RUN mkdir -p /usr/dist/node-app && chown -R node:node /usr/dist/node-app | ||
WORKDIR /usr/src/app | ||
|
||
WORKDIR /usr/dist/node-app | ||
COPY package.json yarn.lock tsconfig.json ecosystem.config.json ./ | ||
|
||
COPY package.json yarn.lock ./ | ||
COPY ./src ./src | ||
|
||
USER node | ||
RUN ls -a | ||
|
||
RUN yarn install --pure-lockfile | ||
RUN yarn install --pure-lockfile && yarn compile | ||
|
||
COPY --chown=node:node . . | ||
# production stage | ||
|
||
EXPOSE 3000 | ||
FROM base as production | ||
|
||
WORKDIR /usr/prod/app | ||
|
||
ENV NODE_ENV=production | ||
|
||
COPY package.json yarn.lock ecosystem.config.json ./ | ||
|
||
RUN yarn install --production --pure-lockfile | ||
|
||
COPY --from=base /usr/src/app/dist ./dist |
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 |
---|---|---|
|
@@ -219,7 +219,9 @@ SMTP_PORT=587 | |
SMTP_USERNAME=email-server-username | ||
SMTP_PASSWORD=email-server-password | ||
[email protected] | ||
FRONT_URL=http://localhost:5000 | ||
|
||
# URL of client application | ||
CLIENT_URL=http://localhost:5000 | ||
``` | ||
|
||
## Project Structure | ||
|
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 |
---|---|---|
@@ -1,6 +1,14 @@ | ||
version: '3' | ||
|
||
services: | ||
node-app: | ||
container_name: node-app-dev | ||
mongo: | ||
volumes: | ||
- ./data:/data/db | ||
|
||
app: | ||
container_name: ts-node-app-dev | ||
command: yarn dev -L | ||
|
||
volumes: | ||
mongo-data: | ||
driver: local |
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
version: '3' | ||
|
||
services: | ||
node-app: | ||
container_name: node-app-prod | ||
app: | ||
container_name: ts-node-app-prod | ||
build: | ||
target: production | ||
command: yarn start |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
version: '3' | ||
|
||
services: | ||
node-app: | ||
container_name: node-app-test | ||
command: yarn test | ||
app: | ||
container_name: ts-node-app-test | ||
command: yarn test: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 |
---|---|---|
@@ -1,32 +1,36 @@ | ||
version: '3' | ||
|
||
services: | ||
node-app: | ||
build: . | ||
image: node-app | ||
environment: | ||
- MONGODB_URL=mongodb://mongodb:27017/node-app | ||
mongo: | ||
container_name: mongo | ||
image: mongo:4.2.1-bionic | ||
restart: always | ||
ports: | ||
- '3000:3000' | ||
depends_on: | ||
- mongodb | ||
volumes: | ||
- .:/usr/dist/node-app | ||
- "27018:27017" | ||
networks: | ||
- node-app-network | ||
|
||
mongodb: | ||
image: mongo:4.2.1-bionic | ||
- backend | ||
app: | ||
container_name: ts-node-app | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
target: base | ||
restart: always | ||
env_file: .env | ||
expose: | ||
- ${PORT} | ||
ports: | ||
- '27017:27017' | ||
volumes: | ||
- dbdata:/data/db | ||
- ${PORT}:${PORT} | ||
environment: | ||
- MONGODB_URL=mongodb://mongo:27017/node-boilerplate | ||
- CLIENT_URL=${CLIENT_URL} | ||
links: | ||
- mongo | ||
depends_on: | ||
- mongo | ||
networks: | ||
- node-app-network | ||
|
||
volumes: | ||
dbdata: | ||
- backend | ||
|
||
networks: | ||
node-app-network: | ||
driver: bridge | ||
backend: | ||
driver: bridge |
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
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
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