Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack config & build images #5

Merged
merged 2 commits into from
Nov 29, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Stack config & build images
m-kus committed Nov 29, 2021
commit dd0bac0384dd308b00b46499bd0cfefe5384a9b5
49 changes: 49 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build
on:
push:
branches:
- 'master'
tags:
- 'v*.*.*'
pull_request:
branches:
- 'master'

jobs:
build:
name: Build
runs-on: ubuntu-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE_NAME: ${{ github.repository }}
steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Log in to the registry
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Indexer image tags & labels
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}

- name: Indexer image build & push
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
16 changes: 1 addition & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ name: Release
on:
push:
tags:
- "*.*.*"
- 'v*.*.*'

jobs:
release:
@@ -14,23 +14,9 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v2

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set up enviroment
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF#refs/*/}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: build/metadata/Dockerfile
push: true
tags: "dipdup/metadata:latest,dipdup/metadata:${{ env.RELEASE_VERSION }}"

- name: Publish GitHub release
uses: "marvinpinto/action-automatic-releases@latest"
with:
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -7,14 +7,14 @@ build:
cd cmd/metadata && go build -v -o ../../dist/ .

debug: build
docker-compose -f docker-compose.local.yml up -d db hasura
docker-compose -f docker-compose.yml up -d db hasura
cd dist && POSTGRES_HOST=localhost HASURA_HOST=localhost ./metadata -c ../build/dipdup.yml

up:
docker-compose -f docker-compose.local.yml up -d --build
docker-compose -f docker-compose.yml up -d --build

down:
docker-compose -f docker-compose.local.yml down -v
docker-compose -f docker-compose.yml down -v

metadata:
cd cmd/metadata && go run . -c ../../build/dipdup.yml
3 changes: 3 additions & 0 deletions build/dipdup.yml
Original file line number Diff line number Diff line change
@@ -33,3 +33,6 @@ hasura:
select_limit: 100
allow_aggregation: false
rest: true

prometheus:
url: ${EXPORT_HOST:-0.0.0.0}:2112
47 changes: 0 additions & 47 deletions docker-compose.local.yml

This file was deleted.

77 changes: 10 additions & 67 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
version: "3.7"
version: "3.6"

services:
indexer:
image: ${SWARMLET_REGISTRY}/metadata:latest
image: dipdup/metadata:latest
build:
dockerfile: build/metadata/Dockerfile
context: .
depends_on:
- db
- hasura
env_file:
- .env
restart: always
environment:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-changeme}
- ADMIN_SECRET=${ADMIN_SECRET:-changeme}
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
deploy:
mode: replicated
replicas: 1
networks:
- metadata-network

db:
image: postgres:13
restart: always
volumes:
- db:/var/lib/postgres/data
ports:
- 127.0.0.1:5432:5432
environment:
- POSTGRES_USER=dipdup
- POSTGRES_DB=dipdup
@@ -35,70 +29,19 @@ services:
interval: 10s
timeout: 5s
retries: 5
deploy:
mode: replicated
replicas: 1
networks:
- metadata-network

hasura:
image: hasura/graphql-engine:v2.0.1
depends_on:
- db
ports:
- 127.0.0.1:8080:8080
restart: always
environment:
- HASURA_GRAPHQL_DATABASE_URL=postgres://dipdup:${POSTGRES_PASSWORD:-changeme}@db:5432/dipdup
- HASURA_GRAPHQL_ENABLE_CONSOLE=false
- HASURA_GRAPHQL_DEV_MODE=false
- HASURA_GRAPHQL_ENABLE_CONSOLE=true
- HASURA_GRAPHQL_DEV_MODE=true
- HASURA_GRAPHQL_ENABLED_LOG_TYPES=startup, http-log, webhook-log, websocket-log, query-log
- HASURA_GRAPHQL_ADMIN_SECRET=${ADMIN_SECRET:-changeme}
- HASURA_GRAPHQL_UNAUTHORIZED_ROLE=user
deploy:
mode: replicated
replicas: 1
labels:
- traefik.enable=true
- traefik.http.services.metadata.loadbalancer.server.port=8080
- traefik.http.routers.metadata.rule=Host(`metadata.${ROOT_DOMAIN}`)
- traefik.http.routers.metadata.entrypoints=http,https,ws,wss
- traefik.http.routers.metadata.middlewares=redirect@file
networks:
- metadata-network
- traefik-public

imgproxy:
image: darthsim/imgproxy:latest
restart: always
environment:
- IMGPROXY_TTL=2592000
- IMGPROXY_SO_REUSEPORT=true
healthcheck:
test: [ "CMD", "imgproxy", "health" ]
timeout: 10s
interval: 10s
retries: 3
deploy:
mode: replicated
replicas: 1
labels:
- traefik.enable=true
- traefik.http.services.imgproxy.loadbalancer.server.port=8080
- traefik.http.routers.imgproxy.rule=Host(`thumbnails.${ROOT_DOMAIN}`)
- traefik.http.routers.imgproxy.entrypoints=http,https
- traefik.http.middlewares.imgproxy-ipfs.replacepathregex.regex=^/(.*)
- traefik.http.middlewares.imgproxy-ipfs.replacepathregex.replacement=/insecure/auto/50/50/sm/0/plain/https://ipfs.baking-bad.org/ipfs/$${1}@png
- traefik.http.middlewares.imgproxy-cors.headers.accesscontrolallowmethods=GET,OPTIONS
- traefik.http.middlewares.imgproxy-cors.headers.accesscontrolalloworigin=*
- traefik.http.middlewares.imgproxy-cors.headers.accesscontrolmaxage=100
- traefik.http.routers.imgproxy.middlewares=redirect@file,imgproxy-ipfs,imgproxy-cors
networks:
- metadata-network
- traefik-public

volumes:
db:

networks:
metadata-network:
traefik-public:
external: true
107 changes: 107 additions & 0 deletions stack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
version: "3.7"

services:
indexer:
image: ${DOCKER_REGISTRY}/dipdup-net/metadata:${TAG}
build:
dockerfile: build/metadata/Dockerfile
context: .
depends_on:
- db
- hasura
restart: always
environment:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-changeme}
- ADMIN_SECRET=${ADMIN_SECRET:-changeme}
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
deploy:
mode: replicated
replicas: 1
labels:
- prometheus-job=${METADATA_SERVICE}
- prometheus-port=2112
networks:
- metadata-network
- traefik-public

db:
image: postgres:13
restart: always
volumes:
- db:/var/lib/postgres/data
environment:
- POSTGRES_USER=dipdup
- POSTGRES_DB=dipdup
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-changeme}
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
deploy:
mode: replicated
replicas: 1
networks:
- metadata-network

hasura:
image: hasura/graphql-engine:v2.0.1
depends_on:
- db
restart: always
environment:
- HASURA_GRAPHQL_DATABASE_URL=postgres://dipdup:${POSTGRES_PASSWORD:-changeme}@db:5432/dipdup
- HASURA_GRAPHQL_ENABLE_CONSOLE=false
- HASURA_GRAPHQL_DEV_MODE=false
- HASURA_GRAPHQL_ENABLED_LOG_TYPES=startup, http-log, webhook-log, websocket-log, query-log
- HASURA_GRAPHQL_ADMIN_SECRET=${ADMIN_SECRET:-changeme}
- HASURA_GRAPHQL_UNAUTHORIZED_ROLE=user
deploy:
mode: replicated
replicas: 1
labels:
- traefik.enable=true
- traefik.http.services.${METADATA_SERVICE}.loadbalancer.server.port=8080
- traefik.http.routers.${METADATA_SERVICE}.rule=Host(`${METADATA_SERVICE}.${METADATA_ROOT_DOMAIN}`)
- traefik.http.routers.${METADATA_SERVICE}.entrypoints=https
networks:
- metadata-network
- traefik-public

imgproxy:
image: darthsim/imgproxy:latest
restart: always
environment:
- IMGPROXY_TTL=2592000
- IMGPROXY_SO_REUSEPORT=true
healthcheck:
test: [ "CMD", "imgproxy", "health" ]
timeout: 10s
interval: 10s
retries: 3
deploy:
mode: replicated
replicas: 1
labels:
- traefik.enable=true
- traefik.http.services.${THUMBS_SERVICE}.loadbalancer.server.port=8080
- traefik.http.routers.${THUMBS_SERVICE}.rule=Host(`${THUMBS_SERVICE}.${METADATA_ROOT_DOMAIN}`)
- traefik.http.routers.${THUMBS_SERVICE}.entrypoints=https
- traefik.http.middlewares.imgproxy-ipfs.replacepathregex.regex=^/(.*)
- traefik.http.middlewares.imgproxy-ipfs.replacepathregex.replacement=/insecure/auto/50/50/sm/0/plain/${IPFS_NODE_URI}/ipfs/$${1}@png
- traefik.http.middlewares.imgproxy-cors.headers.accesscontrolallowmethods=GET,OPTIONS
- traefik.http.middlewares.imgproxy-cors.headers.accesscontrolalloworigin=*
- traefik.http.middlewares.imgproxy-cors.headers.accesscontrolmaxage=100
- traefik.http.routers.${THUMBS_SERVICE}.middlewares=imgproxy-ipfs,imgproxy-cors
networks:
- metadata-network
- traefik-public

volumes:
db:

networks:
metadata-network:
traefik-public:
external: true