From 64bbcb738a4aaa2f7e879de5789361fc6e97fd64 Mon Sep 17 00:00:00 2001 From: Nikita Kalyanov Date: Thu, 1 Apr 2021 23:11:58 +0300 Subject: [PATCH] add common docker-compose file for both front and back --- .gitignore | 1 + README.md | 10 ++++++++ back/docker-compose.yaml | 21 ----------------- docker-compose.yaml | 50 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 21 deletions(-) create mode 100644 README.md delete mode 100644 back/docker-compose.yaml create mode 100644 docker-compose.yaml diff --git a/.gitignore b/.gitignore index 9f11b75..8d9bc81 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .idea/ +back/target/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..8fd6483 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +## Run dev env +1. Install Docker and docker-compose +2. run this command (from project root): +```console +docker-compose up -d +``` +3. To clear the env run: +```console +docker-compose down +``` diff --git a/back/docker-compose.yaml b/back/docker-compose.yaml deleted file mode 100644 index 52a384d..0000000 --- a/back/docker-compose.yaml +++ /dev/null @@ -1,21 +0,0 @@ -version: "2.2" - -services: - postgres: - image: postgres:13.2-alpine - restart: always - volumes: - - ./migrations/:/docker-entrypoint-initdb.d/ - ports: - - "5432:5432" - environment: - POSTGRES_PASSWORD: hh - POSTGRES_DB: hh - POSTGRES_USER: hh - healthcheck: - test: ["CMD-SHELL", "pg_isready -U hh"] - interval: 10s - timeout: 5s - retries: 5 - - # add backend service here, built from Dockerfile diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..6e28df9 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,50 @@ +version: '3.4' + +services: + postgres: + image: postgres:13.2-alpine + restart: always + volumes: + - ./back/migrations/:/docker-entrypoint-initdb.d/ + ports: + - "5432:5432" + environment: + POSTGRES_PASSWORD: hh + POSTGRES_DB: hh + POSTGRES_USER: hh + healthcheck: + test: ["CMD-SHELL", "pg_isready -U hh"] + interval: 10s + timeout: 5s + retries: 5 + + back: + image: maven:3.6.3-jdk-11 + restart: always + working_dir: /mnt/app + command: mvn install exec:java + volumes: + - gowork-back-maven-repo:/root/.m2 + - ./back:/mnt/app:Z + ports: + - "8080:8080" + links: + - postgres + depends_on: + - postgres + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080/status"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 180s # first start may be long due to downloading dependencies + front: + build: ./front + ports: + - "3000:80" + links: + - back + depends_on: + - back +volumes: + gowork-back-maven-repo: