Skip to content

Commit

Permalink
feat: standalone docker image (#919)
Browse files Browse the repository at this point in the history
* feat: standalone docker image

* feat: standalone docker image
  • Loading branch information
kkopanidis authored Jan 26, 2024
1 parent 21c70e6 commit 0accd64
Show file tree
Hide file tree
Showing 5 changed files with 253 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/standalone.build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
on:
workflow_dispatch:
push:
branches:
- main
paths:
- "modules/**"
- "libraries/grpc-sdk/**"
- "libraries/module-tools/**"
- "packages/module-tools/**"

env:
REGISTRY: ghcr.io

jobs:
deploy:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
name: Build Conduit standalone
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build conduit base
run: |
DEV=TRUE make all
- name: Build standalone
run: |
docker build -t ghcr.io/conduitplatform/conduit-standalone:dev -f ./standalone.Dockerfile .
- name: Push image
run: |
docker push ghcr.io/conduitplatform/conduit-standalone:dev
46 changes: 46 additions & 0 deletions .github/workflows/standalone.production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
release:
types:
- created

env:
REGISTRY: ghcr.io

jobs:
deploy:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
name: Build Conduit standalone
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to the Dockerhub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Set env
run: echo "RELEASE_VERSION=$(echo ${GITHUB_REF#refs/*/} | sed 's/^v//')" >> $GITHUB_ENV
- name: Build conduit base
run: |
DEV=TRUE make all
- name: Build standalone
run: |
docker build -t ghcr.io/conduitplatform/conduit-standalone:latest -f ./standalone.Dockerfile .
- name: Push image
run: |
docker tag ghcr.io/conduitplatform/conduit-standalone:latest ghcr.io/conduitplatform/conduit-standalone:${{ env.RELEASE_VERSION }}
docker tag ghcr.io/conduitplatform/conduit-standalone:latest conduit-standalone:latest
docker tag ghcr.io/conduitplatform/conduit-standalone:latest conduit-standalone:${{ env.RELEASE_VERSION }}
docker push ghcr.io/conduitplatform/conduit-standalone:latest
docker push ghcr.io/conduitplatform/conduit-standalone:${{ env.RELEASE_VERSION }}
docker push conduit-standalone:latest
docker push conduit-standalone:${{ env.RELEASE_VERSION }}
79 changes: 79 additions & 0 deletions docker/docker-compose.standalone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# ---------------------------------------- Instructions ----------------------------------------
# This compose file deploys a "standalone" version of conduit with most modules
# packaged in a single image. Loki and Prometheus are not deployed, since
# metrics and logs can be viewed directly from the Docker daemon.
#-------------------------------------------------------------------------------------------

version: '3.9'
networks:
default:
name: 'conduit'
services:
# Default Services
conduit:
container_name: 'conduit'
image: 'docker.io/conduitplatform/conduit-standalone:${IMAGE_TAG}'
restart: unless-stopped
depends_on:
- redis
- mongodb
ports:
- '${CORE_GRPC_PORT:-55152}:${CORE_GRPC_PORT:-55152}'
- '${CORE_ADMIN_HTTP_PORT:-3030}:3030'
- '${CORE_ADMIN_SOCKET_PORT:-3031}:3031'
environment:
REDIS_HOST: 'conduit-redis'
REDIS_PORT: '${REDIS_PORT:-6379}'
MASTER_KEY: '${CORE_MASTER_KEY:-M4ST3RK3Y}'
ADMIN_HTTP_PORT: '${ADMIN_HTTP_PORT:-3030}'
ADMIN_SOCKET_PORT: '${ADMIN_SOCKET_PORT:-3031}'
__DEFAULT_HOST_URL: '${ADMIN_DEFAULT_HOST_URL:-http://localhost:3030}'
GRPC_KEY: '${GRPC_KEY}'
DB_CONN_URI: '${DB_CONN_URI:-mongodb://conduit:pass@conduit-mongo:27017/conduit?authSource=admin}'
networks:
default:
aliases:
- conduit
extra_hosts:
- host.docker.internal:host-gateway

ui:
container_name: 'conduit-ui'
image: 'docker.io/conduitplatform/conduit-ui:${UI_IMAGE_TAG}'
restart: unless-stopped
ports:
- '${UI_PORT:-8080}:8080'
environment:
CONDUIT_URL: 'http://conduit:3030'
MASTER_KEY: '${CORE_MASTER_KEY:-M4ST3RK3Y}'

# Dependencies
redis:
container_name: 'conduit-redis'
image: 'docker.io/library/redis:7.0.2'
restart: unless-stopped
ports:
- '${REDIS_PORT:-6379}:6379'

mongodb:
container_name: 'conduit-mongo'
image: 'docker.io/library/mongo:4.4.15'
restart: unless-stopped
ports:
- '${DB_PORT:-27017}:27017'
environment:
MONGO_INITDB_DATABASE: 'conduit'
MONGO_INITDB_ROOT_USERNAME: '${DB_USER:-conduit}'
MONGO_INITDB_ROOT_PASSWORD: '${DB_PASS:-pass}'
profiles: ['mongodb']
networks:
default:
aliases:
- conduit-mongo
volumes:
- mongo:/data/db

# Persistent Volumes
volumes:
mongo:
external: false
15 changes: 15 additions & 0 deletions standalone.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:iron-alpine

WORKDIR /app

COPY --from=conduit-base:latest /app/ /app/

RUN apk update && \
apk add --no-cache --virtual .gyp python3 make g++ && \
yarn global add pm2 && \
yarn install --production --pure-lockfile --non-interactive && \
yarn cache clean && \
apk del .gyp


CMD ["pm2-runtime", "./standalone/ecosystem.config.js"]
74 changes: 74 additions & 0 deletions standalone/ecosystem.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
module.exports = {
apps: [
{
name: 'core',
script: './packages/core/dist/bin/www.js',
env: {
NODE_ENV: 'production',
},
},
{
name: 'database',
script: './modules/database/dist/index.js',
env: {
CONDUIT_SERVER: '0.0.0.0:55152',
GRPC_PORT: '55153',
SERVICE_URL: '0.0.0.0:55153',
},
},
{
name: 'router',
script: './modules/router/dist/index.js',
env: {
CONDUIT_SERVER: '0.0.0.0:55152',
GRPC_PORT: '55167',
SERVICE_URL: '0.0.0.0:55167',
},
},
{
name: 'authentication',
script: './modules/authentication/dist/index.js',
env: {
CONDUIT_SERVER: '0.0.0.0:55152',
GRPC_PORT: '55154',
SERVICE_URL: '0.0.0.0:55154',
},
},
{
name: 'authorization',
script: './modules/authorization/dist/index.js',
env: {
CONDUIT_SERVER: '0.0.0.0:55152',
GRPC_PORT: '55177',
SERVICE_URL: '0.0.0.0:55177',
},
},
{
name: 'email',
script: './modules/email/dist/index.js',
env: {
CONDUIT_SERVER: '0.0.0.0:55152',
GRPC_PORT: '55155',
SERVICE_URL: '0.0.0.0:55155',
},
},
{
name: 'storage',
script: './modules/storage/dist/index.js',
env: {
CONDUIT_SERVER: '0.0.0.0:55152',
GRPC_PORT: '55158',
SERVICE_URL: '0.0.0.0:55158',
},
},
{
name: 'push-notifications',
script: './modules/push-notifications/dist/index.js',
env: {
CONDUIT_SERVER: '0.0.0.0:55152',
GRPC_PORT: '55159',
SERVICE_URL: '0.0.0.0:55159',
},
},
],
};

0 comments on commit 0accd64

Please sign in to comment.