-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,323 additions
and
65 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,16 @@ | ||
DOCKERHUB_NAME=your_docker_username | ||
IMAGE_NAME=image_name | ||
IMAGE_VERSION=0.0.0 | ||
|
||
EXPRESS_CONTAINER_PORT=8080 | ||
EXPRESS_HOST_PORT=8080 | ||
|
||
POSTGRES_HOST_PORT=5432 | ||
POSTGRES_CONTAINER_PORT=5432 | ||
POSTGRES_HOSTNAME=postgres-primary-db | ||
POSTGRES_USER=postgres_user | ||
POSTGRES_PASSWORD=password | ||
POSTGRES_DB=project_db | ||
|
||
REDIS_HOST_PORT=6379 | ||
REDIS_CONTAINER_PORT=6379 |
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 |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
|
||
# misc | ||
.DS_Store | ||
.env | ||
.env.local | ||
.env.development.local | ||
.env.test.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Built from Node latest Alpine | ||
FROM node:10.0 | ||
|
||
# Specify an optional argument with a default value | ||
ARG app_directory=/src/app | ||
ARG NODE_ENV=development | ||
|
||
# Set the app directory as the context for all commands and entry to the container | ||
WORKDIR ${app_directory} | ||
|
||
# ONLY copy over the package.json to install NPM packages | ||
COPY package.json . | ||
|
||
# Install node module dependencies | ||
RUN npm install | ||
|
||
# Add the rest of the project files(most builds will start from here based on cache) | ||
COPY . . | ||
|
||
# Start the node application as you normally would | ||
CMD ["node", "./server/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 |
---|---|---|
@@ -1,68 +1,19 @@ | ||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). | ||
Use `npm run start` to start the react server | ||
|
||
## Available Scripts | ||
`docker-compose up` to start the backend server along with postgres and redis. | ||
|
||
In the project directory, you can run: | ||
` | ||
"proxy": "http://localhost:8080", | ||
"nodemonConfig": { | ||
"watch": ["server"] | ||
}, | ||
` | ||
The above configurations tells the react proxy server to redirect all api calls to the backend docker instance. The `nodemonConfig` tells nodemon to only watch the server dir. | ||
|
||
### `npm start` | ||
The way the knexfile is setup, the development section allow the user to run the knex migration from the host computer and is routed to the docker instance using localhost. The production section is used by docker to setup the postgres DB and it's connections to the rest of the docker containers. | ||
|
||
Runs the app in the development mode.<br> | ||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | ||
This is controlled using the `ENVIRONMENT` property within the docker-compose.override.yml file, under the environment section. | ||
|
||
The page will reload if you make edits.<br> | ||
You will also see any lint errors in the console. | ||
`knex migrate:latest` will run any migrations made, but this needs to be run in the server dir as that is where the knexfile.js is. | ||
|
||
### `npm test` | ||
|
||
Launches the test runner in the interactive watch mode.<br> | ||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. | ||
|
||
### `npm run build` | ||
|
||
Builds the app for production to the `build` folder.<br> | ||
It correctly bundles React in production mode and optimizes the build for the best performance. | ||
|
||
The build is minified and the filenames include the hashes.<br> | ||
Your app is ready to be deployed! | ||
|
||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. | ||
|
||
### `npm run eject` | ||
|
||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!** | ||
|
||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. | ||
|
||
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. | ||
|
||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. | ||
|
||
## Learn More | ||
|
||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). | ||
|
||
To learn React, check out the [React documentation](https://reactjs.org/). | ||
|
||
### Code Splitting | ||
|
||
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting | ||
|
||
### Analyzing the Bundle Size | ||
|
||
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size | ||
|
||
### Making a Progressive Web App | ||
|
||
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app | ||
|
||
### Advanced Configuration | ||
|
||
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration | ||
|
||
### Deployment | ||
|
||
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment | ||
|
||
### `npm run build` fails to minify | ||
|
||
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify | ||
The `npm run dev` script within the package.json file sets up the how docker is going to run the express server using nodemon. |
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,41 @@ | ||
version: '3' | ||
services: | ||
express-server: | ||
image: ${DOCKERHUB_NAME}/${IMAGE_NAME}:${IMAGE_VERSION} | ||
depends_on: | ||
- postgres-primary-db | ||
command: ["npm", "run", "dev"] | ||
container_name: ${IMAGE_NAME} | ||
volumes: | ||
- ".:/src/app/:rw" | ||
env_file: .env | ||
environment: | ||
ENVIRONMENT: production | ||
NODE_ENV: production | ||
ports: | ||
- "${EXPRESS_HOST_PORT}:${EXPRESS_CONTAINER_PORT}" | ||
networks: | ||
- my-app-network | ||
postgres-primary-db: | ||
image: postgres:10.0-alpine | ||
env_file: .env | ||
volumes: | ||
- pg-data-volume:/var/lib/postgresql/data | ||
ports: | ||
- '${POSTGRES_HOST_PORT}:${POSTGRES_CONTAINER_PORT}' | ||
networks: | ||
- my-app-network | ||
redis-server: | ||
image: redis:4.0-alpine | ||
env_file: .env | ||
volumes: | ||
- redis-data-volume:/data | ||
ports: | ||
- '${REDIS_HOST_PORT}:${REDIS_CONTAINER_PORT}' | ||
networks: | ||
- my-app-network | ||
volumes: | ||
pg-data-volume: | ||
redis-data-volume: | ||
networks: | ||
my-app-network: |
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,6 @@ | ||
version: "3" | ||
services: | ||
express-server: | ||
build: . | ||
image: ${DOCKERHUB_NAME}/${IMAGE_NAME}/${IMAGE_VERSION} | ||
env_file: .env |
Oops, something went wrong.