Follow steps to execute this project.
- Install dependencies
$ yarn install
- Start a local server
$ yarn serve
- Compile code
$ yarn build
- Check code quality
$ yarn lint
Dockerize an application.
- Build and run the container in the background
$ docker-compose up -d app
- Run a command in a running container
$ docker-compose exec app <COMMAND>
- Remove the old container before creating the new one
$ docker-compose rm -fs
- Restart up the container in the background
$ docker-compose up -d --build app
- Push images to Docker Cloud
# .gitignore
.DS_Store
node_modules
dist
coverage
+ dev.Dockerfile
+ stage.Dockerfile
+ prod.Dockerfile
*.log
$ docker login
$ docker build -f ./tools/<dev|stage|prod>.Dockerfile -t <IMAGE_NAME>:<IMAGE_TAG> .
# checkout
$ docker images
$ docker tag <IMAGE_NAME>:<IMAGE_TAG> <DOCKER_ID_USER>/<IMAGE_NAME>:<IMAGE_TAG>
$ docker push <DOCKER_ID_USER>/<IMAGE_NAME>:<IMAGE_TAG>
# remove
$ docker rmi <REPOSITORY>:<TAG>
# or
$ docker rmi <IMAGE_ID>
- Pull images from Docker Cloud
# circle.yml
echo "${HEROKU_TOKEN}" | docker login -u "${HEROKU_USERNAME}" --password-stdin registry.heroku.com
- docker build -f ./tools/$DEPLOYMENT_ENVIRONMENT.Dockerfile -t $APP_NAME .
+ docker pull <DOCKER_ID_USER>/<IMAGE_NAME>:<IMAGE_TAG>
- docker tag $APP_NAME registry.heroku.com/$APP_NAME/web
+ docker tag <IMAGE_NAME>:<IMAGE_TAG> registry.heroku.com/<HEROKU_PROJECT>/web
docker push registry.heroku.com/<HEROKU_PROJECT>/web
Set your local environment variables.
// src/env.js
export const NODE_ENV = process.env.NODE_ENV || 'development';
export const HOST = process.env.HOST || '0.0.0.0';
export const PORT = process.env.PORT || 3000;
export const SECRET = process.env.SECRET || 'PUT_YOUR_SECRET_HERE';
// ...
Set your deployment environment variables.
# tools/<dev|stage|prod>.Dockerfile
# envs --
ENV SECRET <PUT_YOUR_SECRET_HERE>
# ...
# -- envs
The structure follows the LIFT Guidelines.
.
├── src
│ ├── core -> core feature module
│ ├── <FEATURE> -> feature modules
│ │ ├── __tests__
│ │ │ ├── <FEATURE>.e2e-spec.js
│ │ │ └── <FEATURE>.spec.js
│ │ ├── _<THING> -> feature of private things
│ │ │ └── ...
│ │ └── <FEATURE>.js
│ ├── shared -> shared feature module
│ ├── app.js
│ ├── env.js
│ └── server.js
├── tools
│ └── ...
├── .editorconfig
├── .eslintrc
├── .gitignore
├── .prettierrc
├── babel.config
├── docker-compose.yml
├── Dockerfile
├── LICENSE
├── package.json
├── processes.js
├── README.md
└── yarn.lock