diff --git a/.env.dist b/.env.dist new file mode 100644 index 0000000..e2cf7aa --- /dev/null +++ b/.env.dist @@ -0,0 +1,8 @@ +# Copying to .env local + +# DB variables for the connection +DB_USER=root +DB_PASSWORD=root +DB_NAME=db +DB_HOST=postgres +DB_PORT=5432 \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f594aac..fabda9d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -50,3 +50,11 @@ Build: Update Travis to only test Node 0.10 (refs #734) Fix: Semi rule incorrectly flagging extra semicolon (fixes #840) Upgrade: Esprima to 1.2, switch to using comment attachment (fixes #730) ``` + +## Branch naming convention + +The branch should have a name that reflects it's purpose. + +The convention is to prefix the branch name with feature-. All the words must be separated by a -. + +Branch name example : feature-user-authentication \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b44bbc1 --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +test: + go test -v ./... + +.PHONY: help +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(firstword $(MAKEFILE_LIST)) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + + +init: ## Init environment and starts docker app + make copy-files + make start + +copy-files: ## Copy files + bash -c "cp .env.dist .env" + +start: ## start the app + docker-compose up --build -d + +stop: ## stop the app + docker-compose stop + +first-run: ## The command you run when you launch the project for the first time, creates your go mod and make init + go mod init + go mod tidy + make init \ No newline at end of file diff --git a/README.md b/README.md index 9c7e6d9..5125090 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,31 @@ # MT5 P2021 Framework 💀 Year project for MT5 +## Requirements + +To run this project you'll need to have docker and yarn installed on your machine. +If you want to develop on this project it's recommended to have `golang` and `docker` installed on your machine. + +## Project setup + +First time you run the project ? Run : + +```sh +make first-run +``` + +This command creates the go mod and tidies dependencies and then call the make init command. + +> If you want more informations about the available make commands, run `make help` + +If you already have the go.mod and go.sum files you can run : + +```sh +make init +# or +make start +``` + ## Contributing Please read [CONTRIBUTING.md](https://github.com/HETIC-MT-P2021/framework_project/blob/main/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..6d5c8ba --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,55 @@ +version: '3' +services: + api: + build: + context: . + dockerfile: docker/go/Dockerfile + ports: + - 8000:8000 + restart: on-failure + volumes: + - ./:/go/src/github.com/HETIC-MT-P2021/framework_project + depends_on: + - postgres + networks: + - backend + environment: + - DB_USER=root + - DB_PASSWORD=root + - DB_NAME=db + - DB_HOST=postgres + - DB_PORT=5432 + + postgres: + image: postgres:latest + environment: + - POSTGRES_USER=root + - POSTGRES_PASSWORD=root + - POSTGRES_DB=db + - DATABASE_HOST=postgres + ports: + - 5432:5432 + volumes: + - postgres:/var/lib/postgresql/data + networks: + - backend + + adminer: + image: adminer + restart: always + ports: + - 8080:8080 + depends_on: + - postgres + networks: + - backend + restart: unless-stopped + +volumes: + api: + postgres: + +# Networks to be created to facilitate communication between containers +networks: + backend: + driver: bridge \ No newline at end of file