From 5edac4c12aed6a91210b1fbb47bd9a314a5451e6 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Mon, 11 Apr 2022 10:30:16 +0530 Subject: [PATCH] feat: allow custom git repos (#771) fixes #770 --- docker-bake.hcl | 18 ++++++++++++++++++ images/nginx/Dockerfile | 9 ++++++--- images/socketio/Dockerfile | 3 ++- images/worker/Dockerfile | 6 ++++-- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/docker-bake.hcl b/docker-bake.hcl index 025694d0..cd47b824 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -13,9 +13,24 @@ variable "ERPNEXT_VERSION" { default = "develop" } +variable "FRAPPE_REPO" { + default = "https://github.com/frappe/frappe" +} + +variable "ERPNEXT_REPO" { + default = "https://github.com/frappe/erpnext" +} + +variable "BENCH_REPO" { + default = "https://github.com/frappe/bench" +} + # Bench image target "bench" { + args = { + GIT_REPO = "${BENCH_REPO}" + } context = "images/bench" target = "bench" tags = ["frappe/bench:latest"] @@ -53,6 +68,9 @@ function "tag" { target "default-args" { args = { + FRAPPE_REPO = "${FRAPPE_REPO}" + ERPNEXT_REPO = "${ERPNEXT_REPO}" + BENCH_REPO = "${BENCH_REPO}" FRAPPE_VERSION = "${FRAPPE_VERSION}" ERPNEXT_VERSION = "${ERPNEXT_VERSION}" # If `ERPNEXT_VERSION` variable contains "v12" use Python 3.7. Else — 3.9. diff --git a/images/nginx/Dockerfile b/images/nginx/Dockerfile index d5949dd7..310ab14c 100644 --- a/images/nginx/Dockerfile +++ b/images/nginx/Dockerfile @@ -14,8 +14,9 @@ RUN mkdir -p sites/assets /out/assets \ && echo frappe >sites/apps.txt ARG FRAPPE_VERSION +ARG FRAPPE_REPO=https://github.com/frappe/frappe # Install development node modules -RUN git clone --depth 1 -b ${FRAPPE_VERSION} https://github.com/frappe/frappe apps/frappe \ +RUN git clone --depth 1 -b ${FRAPPE_VERSION} ${FRAPPE_REPO} apps/frappe \ && yarn --cwd apps/frappe \ # TODO: Currently `yarn run production` doesn't create .build on develop branch: https://github.com/frappe/frappe/issues/15396 && if [ ! -f sites/.build ]; then touch sites/.build; fi \ @@ -32,14 +33,16 @@ RUN install-app frappe FROM assets_builder as erpnext_assets ARG ERPNEXT_VERSION -RUN git clone --depth 1 -b ${ERPNEXT_VERSION} https://github.com/frappe/erpnext apps/erpnext \ +ARG ERPNEXT_REPO=https://github.com/frappe/erpnext +RUN git clone --depth 1 -b ${ERPNEXT_VERSION} ${ERPNEXT_REPO} apps/erpnext \ && install-app erpnext FROM alpine/git as bench # Error pages -RUN git clone --depth 1 https://github.com/frappe/bench /tmp/bench \ +ARG BENCH_REPO=https://github.com/frappe/bench +RUN git clone --depth 1 ${BENCH_REPO} /tmp/bench \ && mkdir /out \ && mv /tmp/bench/bench/config/templates/502.html /out/ diff --git a/images/socketio/Dockerfile b/images/socketio/Dockerfile index b32ad878..bf63380c 100644 --- a/images/socketio/Dockerfile +++ b/images/socketio/Dockerfile @@ -1,7 +1,8 @@ FROM alpine/git as builder ARG FRAPPE_VERSION -RUN git clone --depth 1 -b ${FRAPPE_VERSION} https://github.com/frappe/frappe /opt/frappe +ARG FRAPPE_REPO=https://github.com/frappe/frappe +RUN git clone --depth 1 -b ${FRAPPE_VERSION} ${FRAPPE_REPO} /opt/frappe FROM node:17-alpine diff --git a/images/worker/Dockerfile b/images/worker/Dockerfile index cb517b6b..77fb2588 100644 --- a/images/worker/Dockerfile +++ b/images/worker/Dockerfile @@ -42,8 +42,9 @@ RUN apt-get update \ FROM build_deps as frappe_builder ARG FRAPPE_VERSION +ARG FRAPPE_REPO=https://github.com/frappe/frappe RUN --mount=type=cache,target=/root/.cache/pip \ - git clone --depth 1 -b ${FRAPPE_VERSION} https://github.com/frappe/frappe apps/frappe \ + git clone --depth 1 -b ${FRAPPE_VERSION} ${FRAPPE_REPO} apps/frappe \ && install-app frappe \ && env/bin/pip install -U gevent \ # Link Frappe's node_modules/ to make Website Theme work @@ -54,8 +55,9 @@ RUN --mount=type=cache,target=/root/.cache/pip \ FROM frappe_builder as erpnext_builder ARG ERPNEXT_VERSION +ARG ERPNEXT_REPO=https://github.com/frappe/erpnext RUN --mount=type=cache,target=/root/.cache/pip \ - git clone --depth 1 -b ${ERPNEXT_VERSION} https://github.com/frappe/erpnext apps/erpnext \ + git clone --depth 1 -b ${ERPNEXT_VERSION} ${ERPNEXT_REPO} apps/erpnext \ && install-app erpnext