diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..c13969d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "erpnext/frappe_docker"] + path = erpnext/frappe_docker + url = https://github.com/frappe/frappe_docker diff --git a/erpnext/.gitignore b/erpnext/.gitignore new file mode 100644 index 0000000..b5694f8 --- /dev/null +++ b/erpnext/.gitignore @@ -0,0 +1,3 @@ +.env +secret.env +docker-compose.yml diff --git a/erpnext/README.md b/erpnext/README.md new file mode 100644 index 0000000..c6baab6 --- /dev/null +++ b/erpnext/README.md @@ -0,0 +1,3 @@ +# ERPNext + +Containerfile for the ERPNext backend with the HRMS module included as well as a generator for the Docker Compose config used by JILITS. diff --git a/erpnext/backend.Containerfile b/erpnext/backend.Containerfile new file mode 100644 index 0000000..ebd6862 --- /dev/null +++ b/erpnext/backend.Containerfile @@ -0,0 +1,17 @@ +ARG ERPNEXT_VERSION +FROM alpine:latest +RUN \ + cd /tmp; \ + apk add tar wget; \ + wget https://github.com/frappe/hrms/archive/refs/tags/v1.0.0.tar.gz -O "release.tgz"; \ + mkdir "release"; \ + tar -zxvf "release.tgz" -C "release"; \ + mv "$(find release -mindepth 1 -maxdepth 1 -type d)" "/app"; + +FROM frappe/erpnext-worker:${ERPNEXT_VERSION} +ARG APP_NAME="hrms" +USER root +COPY --from=0 /app/ ../apps/${APP_NAME}/ +RUN chown -R frappe:frappe ../apps/${APP_NAME}/ +RUN --mount=type=cache,target=/root/.cache/pip install-app ${APP_NAME} +USER frappe diff --git a/erpnext/compose.override.yaml b/erpnext/compose.override.yaml new file mode 100644 index 0000000..54ae679 --- /dev/null +++ b/erpnext/compose.override.yaml @@ -0,0 +1,21 @@ +x-erpnext-backend-image: &erpnext_backend_image + image: git.jilits.se/jilits/erpnext-worker:${ERPNEXT_VERSION:?No ERPNext version set} + +services: + configurator: + <<: *erpnext_backend_image + + backend: + <<: *erpnext_backend_image + + queue-short: + <<: *erpnext_backend_image + + queue-default: + <<: *erpnext_backend_image + + queue-long: + <<: *erpnext_backend_image + + scheduler: + <<: *erpnext_backend_image diff --git a/erpnext/frappe_docker b/erpnext/frappe_docker new file mode 160000 index 0000000..d85f54c --- /dev/null +++ b/erpnext/frappe_docker @@ -0,0 +1 @@ +Subproject commit d85f54cd7beaf38e4c553ee354bdc4ff3a4d009e diff --git a/erpnext/main.env b/erpnext/main.env new file mode 100644 index 0000000..84b44a0 --- /dev/null +++ b/erpnext/main.env @@ -0,0 +1,40 @@ +# Reference: https://github.com/frappe/frappe_docker/blob/main/docs/images-and-compose-files.md + +FRAPPE_VERSION=v14.19.1 + +# Only with ERPNext override +ERPNEXT_VERSION=v14.10.1 + +DB_PASSWORD=somethingelse + +# Only if you use external database +DB_HOST= +DB_PORT= + +# Only if you use external Redis +REDIS_CACHE= +REDIS_QUEUE= +REDIS_SOCKETIO= + +# Only with HTTPS override +LETSENCRYPT_EMAIL=mail@example.com + +# These environment variables are not required. + +# Default value is `$$host` which resolves site by host. For example, if your host is `example.com`, +# site's name should be `example.com`, or if host is `127.0.0.1` (local debugging), it should be `127.0.0.1`. +# This variable allows to override described behavior. Let's say you create site named `mysite` +# and do want to access it by `127.0.0.1` host. Than you would set this variable to `mysite`. +FRAPPE_SITE_NAME_HEADER=erp.jilits.se + +# Default value is `127.0.0.1`. Set IP address as our trusted upstream address. +UPSTREAM_REAL_IP_ADDRESS= + +# Default value is `X-Forwarded-For`. Set request header field whose value will be used to replace the client address +UPSTREAM_REAL_IP_HEADER= + +# Allowed values are on|off. Default value is `off`. If recursive search is disabled, +# the original client address that matches one of the trusted addresses +# is replaced by the last address sent in the request header field defined by the real_ip_header directive. +# If recursive search is enabled, the original client address that matches one of the trusted addresses is replaced by the last non-trusted address sent in the request header field. +UPSTREAM_REAL_IP_RECURSIVE= diff --git a/erpnext/mk-compose.sh b/erpnext/mk-compose.sh new file mode 100755 index 0000000..dae88a2 --- /dev/null +++ b/erpnext/mk-compose.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# +# Build Docker Compose configuration +# + +script_dir="$( + cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit 1 + pwd -P +)" +cd "$script_dir" || exit 1 + +cat main.env secret.env >.env || exit 2 +ln -sfn ../.env frappe_docker/.env || exit 3 +. .env || exit 4 + +cd "$script_dir/frappe_docker" || exit 5 + +# Generate YAML +docker compose -p erpnext \ + -f compose.yaml \ + -f overrides/compose.erpnext.yaml \ + -f overrides/compose.mariadb.yaml \ + -f overrides/compose.redis.yaml \ + -f overrides/compose.noproxy.yaml \ + -f ../compose.override.yaml \ + config >../docker-compose.yml diff --git a/erpnext/mk-container.sh b/erpnext/mk-container.sh new file mode 100755 index 0000000..a9d0275 --- /dev/null +++ b/erpnext/mk-container.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# +# Build custom backend container +# + +script_dir="$( + cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit 1 + pwd -P +)" +cd "$script_dir" || exit 1 + +. main.env || exit 2 + +DOCKER_BUILDKIT=1 docker build . -f backend.Containerfile --build-arg ERPNEXT_VERSION="${ERPNEXT_VERSION:?}" -t "jilits/erpnext-worker:${ERPNEXT_VERSION}" -t "git.jilits.se/jilits/erpnext-worker:${ERPNEXT_VERSION}"