diff --git a/README.md b/README.md index 83c37e816..673fdfa8a 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Trying out Zally is easy. You can build and run the whole Zally stack (web-ui, s and database) by executing: ```bash -./build-and-run.sh +docker compose up -d ``` Web UI is accessible on `http://localhost:8080`; Zally server on `http://localhost:8000` diff --git a/build-and-run.sh b/build-and-run.sh deleted file mode 100755 index a86083d8d..000000000 --- a/build-and-run.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash -# This script starts the Zally components via docker-compose: -# the server component is separately built inside its own container. - - -set -ex - -hash yarn 2>/dev/null || { echo >&2 "yarn is not installed.."; exit 1; } - -pushd $(dirname $0) > /dev/null -SCRIPT_DIR=$(pwd -P) -popd > /dev/null - -SERVER_DIR=${SCRIPT_DIR}/server -WEB_UI_DIR=${SCRIPT_DIR}/web-ui - -# Build web ui -cd ${WEB_UI_DIR} && yarn && yarn build - -# Docker-compose -cd ${SCRIPT_DIR} && docker-compose up --build diff --git a/docker-compose.yaml b/docker-compose.yaml index 44fdb5b90..e5a2ccc94 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -11,15 +11,15 @@ services: web-ui: build: ./web-ui environment: - - ZALLY_API_URL=${ZALLY_API_URL:-http://localhost:8000} + - ZALLY_API_URL=${ZALLY_API_URL:-http://localhost:8000} depends_on: - - server + - server links: - - server:server.local + - server:server.local ports: - - "8080:3000" + - "8080:3000" healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:3000"] + test: [ "CMD", "curl", "-f", "http://localhost:3000" ] interval: 5s timeout: 2s retries: 10 @@ -27,32 +27,35 @@ services: server: build: ./server depends_on: - - postgres + - postgres links: - - postgres:postgres.local + - postgres:postgres.local ports: - - "8000:8000" + - "8000:8000" healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:7979/health"] + test: [ "CMD", "curl", "-f", "http://localhost:7979/health" ] interval: 5s timeout: 2s retries: 10 environment: - - SPRING_PROFILES_ACTIVE=dev - - SPRING_DATASOURCE_URL=jdbc:postgresql://postgres.local:5432/zally - - SPRING_DATASOURCE_USERNAME=postgres - - SPRING_DATASOURCE_PASSWORD=postgres - - MANAGEMENT_PORT=7979 - - TOKEN_INFO_URI=https://url.not.set + - SPRING_PROFILES_ACTIVE=dev + - SPRING_DATASOURCE_URL=jdbc:postgresql://postgres.local:5432/zally + - SPRING_DATASOURCE_USERNAME=postgres + - SPRING_DATASOURCE_PASSWORD=postgres + - MANAGEMENT_PORT=7979 + - TOKEN_INFO_URI=https://url.not.set postgres: image: postgres:13 environment: - - POSTGRES_PASSWORD=postgres - - POSTGRES_DB=zally - ports: - - "54321:5432" + - POSTGRES_PASSWORD=postgres + - POSTGRES_DB=zally + volumes: + - "postgres-data:/var/lib/postgresql/data" healthcheck: - test: ["CMD", "pg_isready", "-U", "postgres"] + test: [ "CMD", "pg_isready", "-U", "postgres" ] interval: 10s timeout: 5s retries: 5 + +volumes: + postgres-data: diff --git a/server/.dockerignore b/server/.dockerignore new file mode 100644 index 000000000..17f41870f --- /dev/null +++ b/server/.dockerignore @@ -0,0 +1,3 @@ +.gradle +build +Dockerfile diff --git a/server/Dockerfile b/server/Dockerfile index c43afedac..658518634 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -1,9 +1,17 @@ +FROM eclipse-temurin:17 as builder + +WORKDIR /var/app + +COPY . . +RUN ./gradlew +RUN ./gradlew build + FROM eclipse-temurin:17 LABEL org.opencontainers.image.authors="https://opensource.zalando.com/" COPY zally-server/src/main/resources/api/zally-api.yaml /zalando-apis/zally-api.yaml -COPY zally-server/build/libs/zally-server.jar / +COPY --from=builder /var/app/zally-server/build/libs/zally-server.jar / EXPOSE 8080 diff --git a/web-ui/.dockerignore b/web-ui/.dockerignore index 2c085d1d2..a425943ca 100644 --- a/web-ui/.dockerignore +++ b/web-ui/.dockerignore @@ -1,2 +1,3 @@ node_modules target +Dockerfile diff --git a/web-ui/Dockerfile b/web-ui/Dockerfile index fc7d12fc7..ac0aa0c1f 100644 --- a/web-ui/Dockerfile +++ b/web-ui/Dockerfile @@ -2,6 +2,8 @@ FROM registry.opensource.zalan.do/library/node-18-alpine:latest MAINTAINER "http://zalando.github.io/" +RUN apk --no-cache add curl + COPY package.json ./ COPY yarn.lock ./