Skip to content

Commit

Permalink
feat: update configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
BohdanK-W32 committed Feb 13, 2024
1 parent a58a274 commit 2b25036
Show file tree
Hide file tree
Showing 9 changed files with 304 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ FRAPPE_SITE_NAME_HEADER=
# List of sites for letsencrypt certificates quoted with backtick (`) and separated by comma (,)
# More https://doc.traefik.io/traefik/routing/routers/#rule
# About acme https://doc.traefik.io/traefik/https/acme/#domain-definition
SITES=`erp.zapal.tech`
SITES=`localhost`
43 changes: 43 additions & 0 deletions .github/workflows/production-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Create and publish a Docker image

on:
push:
branches: ['production']

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: 'DOTENV_KEY=${{ secrets.DOTENV_KEY }}'
11 changes: 7 additions & 4 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ x-depends-on-configurator: &depends_on_configurator
x-backend-defaults: &backend_defaults
<<: [*depends_on_configurator, *customizable_image]
volumes:
- ./sites:/home/frappe/frappe-bench/sites
- sites:/home/zapal/frappe-bench/sites

services:
configurator:
Expand Down Expand Up @@ -52,7 +52,7 @@ services:
PROXY_READ_TIMEOUT: ${PROXY_READ_TIMEOUT:-120}
CLIENT_MAX_BODY_SIZE: ${CLIENT_MAX_BODY_SIZE:-50m}
volumes:
- ./sites:/home/frappe/frappe-bench/sites
- sites:/home/zapal/frappe-bench/sites
depends_on:
- backend
- websocket
Expand All @@ -61,9 +61,9 @@ services:
<<: [*depends_on_configurator, *customizable_image]
command:
- node
- /home/frappe/frappe-bench/apps/frappe/socketio.js
- /home/zapal/frappe-bench/apps/frappe/socketio.js
volumes:
- ./sites:/home/frappe/frappe-bench/sites
- sites:/home/zapal/frappe-bench/sites

queue-short:
<<: *backend_defaults
Expand All @@ -76,3 +76,6 @@ services:
scheduler:
<<: *backend_defaults
command: bench schedule

volumes:
sites:
8 changes: 8 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ variable "HRMS_VERSION" {
default = "version-15"
}

variable "INSIGHTS_VERSION" {
default = "develop"
}

variable "FRAPPE_REPO" {
default = "https://github.com/zapal-tech/erp-frappe"
}
Expand All @@ -33,6 +37,10 @@ variable "HRMS_REPO" {
default = "https://github.com/zapal-tech/erp-hrms"
}

variable "INSIGHTS_REPO" {
default = "https://github.com/zapal-tech/erp-insights"
}

variable "BENCH_REPO" {
default = "https://github.com/frappe/bench"
}
Expand Down
211 changes: 211 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
name: erp
services:
backend:
depends_on:
configurator:
condition: service_completed_successfully
required: true
image: zapal-tech/erp:latest
networks:
default: null
volumes:
- type: volume
source: sites
target: /home/zapal/frappe-bench/sites
volume: {}
configurator:
command:
- |
ls -1 apps > sites/apps.txt; bench set-config -g db_host $$DB_HOST; bench set-config -gp db_port $$DB_PORT; bench set-config -g redis_cache "redis://$$REDIS_CACHE"; bench set-config -g redis_queue "redis://$$REDIS_QUEUE"; bench set-config -g redis_socketio "redis://$$REDIS_QUEUE"; bench set-config -gp socketio_port $$SOCKETIO_PORT;
depends_on:
db:
condition: service_healthy
required: true
redis-cache:
condition: service_started
required: true
redis-queue:
condition: service_started
required: true
entrypoint:
- bash
- -c
environment:
DB_HOST: db
DB_PORT: "3306"
REDIS_CACHE: redis-cache:6379
REDIS_QUEUE: redis-queue:6379
SOCKETIO_PORT: "9000"
image: zapal-tech/erp:latest
networks:
default: null
volumes:
- type: volume
source: sites
target: /home/zapal/frappe-bench/sites
volume: {}
db:
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --skip-character-set-client-handshake
- --skip-innodb-read-only-compressed
environment:
MYSQL_ROOT_PASSWORD: "123"
healthcheck:
test:
- CMD-SHELL
- mysqladmin ping -h localhost --password=123
interval: 1s
retries: 15
image: mariadb:10.6
networks:
default: null
volumes:
- type: volume
source: db-data
target: /var/lib/mysql
volume: {}
frontend:
command:
- nginx-entrypoint.sh
depends_on:
backend:
condition: service_started
required: true
websocket:
condition: service_started
required: true
environment:
BACKEND: backend:8000
CLIENT_MAX_BODY_SIZE: 50m
FRAPPE_SITE_NAME_HEADER: $$host
PROXY_READ_TIMEOUT: "120"
SOCKETIO: websocket:9000
UPSTREAM_REAL_IP_ADDRESS: 127.0.0.1
UPSTREAM_REAL_IP_HEADER: X-Forwarded-For
UPSTREAM_REAL_IP_RECURSIVE: "off"
image: zapal-tech/erp:latest
networks:
default: null
ports:
- mode: ingress
target: 8080
published: "8080"
protocol: tcp
volumes:
- type: volume
source: sites
target: /home/zapal/frappe-bench/sites
volume: {}
queue-long:
command:
- bench
- worker
- --queue
- long,default,short
depends_on:
configurator:
condition: service_completed_successfully
required: true
image: zapal-tech/erp:latest
networks:
default: null
volumes:
- type: volume
source: sites
target: /home/zapal/frappe-bench/sites
volume: {}
queue-short:
command:
- bench
- worker
- --queue
- short,default
depends_on:
configurator:
condition: service_completed_successfully
required: true
image: zapal-tech/erp:latest
networks:
default: null
volumes:
- type: volume
source: sites
target: /home/zapal/frappe-bench/sites
volume: {}
redis-cache:
image: redis:6.2-alpine
networks:
default: null
volumes:
- type: volume
source: redis-cache-data
target: /data
volume: {}
redis-queue:
image: redis:6.2-alpine
networks:
default: null
volumes:
- type: volume
source: redis-queue-data
target: /data
volume: {}
scheduler:
command:
- bench
- schedule
depends_on:
configurator:
condition: service_completed_successfully
required: true
image: zapal-tech/erp:latest
networks:
default: null
volumes:
- type: volume
source: sites
target: /home/zapal/frappe-bench/sites
volume: {}
websocket:
command:
- node
- /home/zapal/frappe-bench/apps/frappe/socketio.js
depends_on:
configurator:
condition: service_completed_successfully
required: true
image: zapal-tech/erp:latest
networks:
default: null
volumes:
- type: volume
source: sites
target: /home/zapal/frappe-bench/sites
volume: {}
networks:
default:
name: erp_default
volumes:
db-data:
name: erp_db-data
redis-cache-data:
name: erp_redis-cache-data
redis-queue-data:
name: erp_redis-queue-data
sites:
name: erp_sites
x-backend-defaults:
depends_on:
configurator:
condition: service_completed_successfully
image: zapal-tech/erp:latest
volumes:
- sites:/home/zapal/frappe-bench/sites
x-customizable-image:
image: zapal-tech/erp:latest
x-depends-on-configurator:
depends_on:
configurator:
condition: service_completed_successfully
20 changes: 13 additions & 7 deletions images/custom/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,25 @@ RUN bench init \
--no-backups \
--skip-redis-config-generation \
--verbose \
/home/zapal/frappe-bench && \
cd /home/zapal/frappe-bench && \
bench get-app --branch=${ERPNEXT_BRANCH} --resolve-deps erpnext ${ERPNEXT_REPO} && \
bench get-app --branch=${HRMS_BRANCH} --resolve-deps hrms ${HRMS_REPO} && \
bench get-app --branch=${INSIGHTS_BRANCH} --resolve-deps insights ${INSIGHTS_REPO} && \
echo "{}" > sites/common_site_config.json && \
find apps -mindepth 1 -path "*/.git" | xargs rm -fr
/home/zapal/frappe-bench

WORKDIR /home/zapal/frappe-bench

RUN bench get-app --branch=${ERPNEXT_BRANCH} --resolve-deps erpnext ${ERPNEXT_REPO}
RUN bench get-app --branch=${HRMS_BRANCH} --resolve-deps hrms ${HRMS_REPO}
# RUN bench get-app --branch=${INSIGHTS_BRANCH} --resolve-deps insights ${INSIGHTS_REPO}

RUN echo "frappe\nhrms\nerpnext" > sites/apps.txt
RUN echo "{}" > sites/common_site_config.json
RUN find apps -mindepth 1 -path "*/.git" | xargs rm -fr

FROM base as erp

USER zapal

COPY --from=builder --chown=zapal:zapal /home/zapal/frappe-bench /home/zapal/frappe-bench
COPY /templates/nginx/erp.conf.template /templates/nginx/erp.conf.template
COPY /usr/local/bin/nginx-entrypoint.sh /usr/local/bin/nginx-entrypoint.sh

WORKDIR /home/zapal/frappe-bench

Expand Down
Loading

0 comments on commit 2b25036

Please sign in to comment.