This is a dockerized application.
For local application starting (for development) make sure that you have locally installed next applications:
docker >= 19
(installing manual)docker-compose >= 1.24
(installing manualmake >= 4.2.1
(install:apt-get install make
)
- Clone this repository on your machine
cd challenge
- Rename
www/.env.example
towww/.env.local
(cp www/.env.example www/.env.local
) and fill in values if it's need - Rename
.env.example
to.env.local
(cp .env.example .env.local
) and fill in values if it's need make up
make start-dev
- Open app in your browser
[NOTE] To change data source you need to set JSON_SOURCE_PATH
environment variable. You can specify any HTTP
url or path to file in your file system. By default, it's data/data.json
.
This application uses next services:
- Next.js 12.0.4
- PostgreSQL 13.1
- Hasura 2.0.10
Declaration of all services can be found into ./docker-compose.*.yaml
files.
Most used commands declared in ./Makefile
file:
Command signature | Description |
---|---|
make help |
Get this help |
make up |
Set up application (start all containers in background and migrate db) |
make down |
Stop application |
make start-dev |
Start application for local development |
make shell |
Shell node container |
make sync-db |
Sync all db changes (you can specify argument MODE to production /local (by default) |
make init-release |
Initialize first release on AWS |
make release |
Start release on AWS (Deploy infrastructure on AWS) |
make destroy-release |
Destroy all resources for created release on AWS |
make deploy |
Deploy app changes to AWS |
docker-compose down -v |
Stop all application containers and remove all application data (database, etc) |
After application starting you can open http://localhost:3000 in your browser.
Go to example
[NOTE] Yeap, in future all this applications and steps will be cool to move to CI/CD.
For deploying your application make sure that you have locally installed next applications:
docker >= 19
(installing manual)docker-compose >= 1.24
(installing manual)make >= 4.2.1
(install:apt-get install make
)terraform >= 1.0.11
(installing manual)aws-cli
(installing manual) or any another way to work with your AWS resources.
- Create an IAM account in your AWS (you'll get
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
) - Run
aws configure
and enterAWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
or you can use any another way to auth yourself into AWS account.
- Move to project root
make init-release
- Rename
example.tfvars
toproduction.tfvars
(cp infrastracture/terraform/example.tfvars infrastracture/terraform/production.tfvars
) and fill in all values. make release
- Rename
www/.env.example.production
towww/.env.production
(cp www/.env.example.production www/.env.production
) - Rename
.env.example.production
to.env.production
(cp .env.example.production .env.production
) - You'll get Terraform output from previous command, so use it and fill in
.env.production
andwww/.env.production
variables. make deploy
(*)make sync-db mode=production
[NOTE] (*) In order to push docker image to AWS ECR you need to log in into ECR (aws ecr get-login
or any other appropriate way How to log in into AWS ECR or Auth into AWS ECR)
- Make changes in your code
- Commit it (optional)
make deploy
make sync-db mode=production
(only if you have any changes in your Hasura)