mirror of
https://github.com/frappe/frappe_docker.git
synced 2024-12-24 11:05:29 +00:00
Merge pull request #476 from revant/feat
This commit is contained in:
commit
5c3e8b1467
@ -1,5 +1,9 @@
|
|||||||
# Frappe Bench Dockerfile
|
# Frappe Bench Dockerfile
|
||||||
FROM debian:buster-slim
|
FROM debian:buster-slim
|
||||||
|
|
||||||
|
ARG GIT_REPO=https://github.com/frappe/bench.git
|
||||||
|
ARG GIT_BRANCH=develop
|
||||||
|
|
||||||
LABEL author=frappé
|
LABEL author=frappé
|
||||||
|
|
||||||
RUN apt-get update -y && apt-get install \
|
RUN apt-get update -y && apt-get install \
|
||||||
@ -71,7 +75,7 @@ WORKDIR /home/frappe
|
|||||||
|
|
||||||
# Clone and install bench in the local user home directory
|
# Clone and install bench in the local user home directory
|
||||||
# For development, bench source is located in ~/.bench
|
# For development, bench source is located in ~/.bench
|
||||||
RUN git clone https://github.com/frappe/bench.git .bench \
|
RUN git clone ${GIT_REPO} -b ${GIT_BRANCH} .bench \
|
||||||
&& pip3 install --user -e .bench
|
&& pip3 install --user -e .bench
|
||||||
|
|
||||||
# Export python executables for Dockerfile
|
# Export python executables for Dockerfile
|
||||||
@ -87,13 +91,12 @@ RUN bash -c "bench --version"
|
|||||||
# !!! UPDATE NODEJS PERIODICALLY WITH LATEST VERSIONS !!!
|
# !!! UPDATE NODEJS PERIODICALLY WITH LATEST VERSIONS !!!
|
||||||
# https://nodejs.org/en/about/releases/
|
# https://nodejs.org/en/about/releases/
|
||||||
# https://nodejs.org/download/release/latest-v10.x/
|
# https://nodejs.org/download/release/latest-v10.x/
|
||||||
# https://nodejs.org/download/release/latest-v12.x/
|
# https://nodejs.org/download/release/latest-v14.x/
|
||||||
# https://nodejs.org/download/release/latest-v13.x/
|
ENV NODE_VERSION=14.17.0
|
||||||
ENV NODE_VERSION=12.20.0
|
ENV NODE_VERSION_FRAPPEV11=10.24.1
|
||||||
ENV NODE_VERSION_FRAPPEV11=10.23.0
|
|
||||||
|
|
||||||
# Install nvm with node
|
# Install nvm with node
|
||||||
RUN wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh
|
RUN wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh
|
||||||
RUN chmod +x install.sh
|
RUN chmod +x install.sh
|
||||||
RUN ./install.sh
|
RUN ./install.sh
|
||||||
ENV NVM_DIR=/home/frappe/.nvm
|
ENV NVM_DIR=/home/frappe/.nvm
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
ARG NODE_IMAGE_TAG=12-buster-slim
|
ARG NODE_IMAGE_TAG=14-buster-slim
|
||||||
ARG GIT_BRANCH=develop
|
|
||||||
ARG DOCKER_REGISTRY_PREFIX=frappe
|
ARG DOCKER_REGISTRY_PREFIX=frappe
|
||||||
|
ARG IMAGE_TAG=develop
|
||||||
|
|
||||||
FROM node:${NODE_IMAGE_TAG}
|
FROM node:${NODE_IMAGE_TAG}
|
||||||
|
|
||||||
ARG GIT_BRANCH
|
ARG GIT_REPO=https://github.com/frappe/erpnext
|
||||||
|
ARG GIT_BRANCH=develop
|
||||||
|
|
||||||
COPY build/erpnext-nginx/install_app.sh /install_app
|
COPY build/erpnext-nginx/install_app.sh /install_app
|
||||||
RUN chmod +x /install_app && \
|
RUN chmod +x /install_app && \
|
||||||
apt-get update -y && \
|
apt-get update -y && \
|
||||||
@ -11,9 +14,9 @@ RUN chmod +x /install_app && \
|
|||||||
apt-get clean && \
|
apt-get clean && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
RUN /install_app erpnext https://github.com/frappe/erpnext ${GIT_BRANCH}
|
RUN /install_app erpnext ${GIT_REPO} ${GIT_BRANCH}
|
||||||
|
|
||||||
FROM ${DOCKER_REGISTRY_PREFIX}/frappe-nginx:${GIT_BRANCH}
|
FROM ${DOCKER_REGISTRY_PREFIX}/frappe-nginx:${IMAGE_TAG}
|
||||||
|
|
||||||
COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/
|
COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/
|
||||||
COPY --from=0 /rsync /rsync
|
COPY --from=0 /rsync /rsync
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
ARG GIT_BRANCH=develop
|
ARG IMAGE_TAG=develop
|
||||||
ARG DOCKER_REGISTRY_PREFIX=frappe
|
ARG DOCKER_REGISTRY_PREFIX=frappe
|
||||||
FROM ${DOCKER_REGISTRY_PREFIX}/frappe-worker:${GIT_BRANCH}
|
FROM ${DOCKER_REGISTRY_PREFIX}/frappe-worker:${IMAGE_TAG}
|
||||||
|
|
||||||
ARG GIT_BRANCH
|
ARG GIT_REPO=https://github.com/frappe/erpnext
|
||||||
RUN install_app erpnext https://github.com/frappe/erpnext ${GIT_BRANCH}
|
ARG GIT_BRANCH=develop
|
||||||
|
|
||||||
|
RUN install_app erpnext ${GIT_REPO} ${GIT_BRANCH}
|
||||||
|
@ -4,14 +4,17 @@
|
|||||||
# by Website Manager role in Frappe Framework
|
# by Website Manager role in Frappe Framework
|
||||||
FROM python:3.7-slim-buster
|
FROM python:3.7-slim-buster
|
||||||
|
|
||||||
|
ARG GIT_REPO=https://github.com/frappe/frappe
|
||||||
|
ARG GIT_BRANCH=develop
|
||||||
|
|
||||||
ENV NVM_DIR=/root/.nvm
|
ENV NVM_DIR=/root/.nvm
|
||||||
ENV NODE_VERSION=12.20.0
|
ENV NODE_VERSION=14.17.0
|
||||||
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
|
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
|
||||||
RUN apt-get update -y \
|
RUN apt-get update -y \
|
||||||
&& apt-get install wget python2 git build-essential -y \
|
&& apt-get install wget python2 git build-essential -y \
|
||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
&& wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh \
|
&& wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh \
|
||||||
&& chmod +x install.sh \
|
&& chmod +x install.sh \
|
||||||
&& ./install.sh \
|
&& ./install.sh \
|
||||||
&& . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} \
|
&& . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} \
|
||||||
@ -21,10 +24,9 @@ WORKDIR /home/frappe/frappe-bench
|
|||||||
RUN mkdir -p /home/frappe/frappe-bench/sites \
|
RUN mkdir -p /home/frappe/frappe-bench/sites \
|
||||||
&& echo "frappe" > /home/frappe/frappe-bench/sites/apps.txt
|
&& echo "frappe" > /home/frappe/frappe-bench/sites/apps.txt
|
||||||
|
|
||||||
ARG GIT_BRANCH=develop
|
|
||||||
RUN mkdir -p apps sites/assets/css \
|
RUN mkdir -p apps sites/assets/css \
|
||||||
&& cd apps \
|
&& cd apps \
|
||||||
&& git clone --depth 1 https://github.com/frappe/frappe --branch $GIT_BRANCH
|
&& git clone --depth 1 ${GIT_REPO} --branch $GIT_BRANCH
|
||||||
|
|
||||||
RUN cd /home/frappe/frappe-bench/apps/frappe \
|
RUN cd /home/frappe/frappe-bench/apps/frappe \
|
||||||
&& yarn \
|
&& yarn \
|
||||||
|
@ -6,9 +6,8 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
rsync -a --delete /var/www/html/assets/js /assets
|
rsync -a --delete /var/www/html/assets/* /assets
|
||||||
rsync -a --delete /var/www/html/assets/css /assets
|
|
||||||
rsync -a --delete /var/www/html/assets/frappe /assets
|
|
||||||
. /rsync
|
. /rsync
|
||||||
|
|
||||||
touch /var/www/html/sites/.build -r $(ls -td /assets/* | head -n 1)
|
touch /var/www/html/sites/.build -r $(ls -td /assets/* | head -n 1)
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
FROM alpine/git
|
||||||
|
|
||||||
|
ARG GIT_REPO=https://github.com/frappe/frappe.git
|
||||||
|
ARG GIT_BRANCH=develop
|
||||||
|
|
||||||
|
RUN git clone ${GIT_REPO} /opt/frappe -b ${GIT_BRANCH} --depth 1
|
||||||
|
|
||||||
FROM node:buster-slim
|
FROM node:buster-slim
|
||||||
|
|
||||||
# Add frappe user
|
# Add frappe user
|
||||||
@ -9,15 +16,8 @@ RUN mkdir -p /home/frappe/frappe-bench/sites /home/frappe/frappe-bench/apps/frap
|
|||||||
|
|
||||||
# Download socketio and purge curl package
|
# Download socketio and purge curl package
|
||||||
COPY build/frappe-socketio/package.json /home/frappe/frappe-bench/apps/frappe
|
COPY build/frappe-socketio/package.json /home/frappe/frappe-bench/apps/frappe
|
||||||
ARG GIT_BRANCH=develop
|
COPY --from=0 /opt/frappe/socketio.js /home/frappe/frappe-bench/apps/frappe/socketio.js
|
||||||
RUN apt-get update && apt-get install -y curl \
|
COPY --from=0 /opt/frappe/node_utils.js /home/frappe/frappe-bench/apps/frappe/node_utils.js
|
||||||
&& cd /home/frappe/frappe-bench/apps/frappe \
|
|
||||||
&& curl "https://raw.githubusercontent.com/frappe/frappe/$GIT_BRANCH/socketio.js" \
|
|
||||||
--output /home/frappe/frappe-bench/apps/frappe/socketio.js \
|
|
||||||
&& curl "https://raw.githubusercontent.com/frappe/frappe/$GIT_BRANCH/node_utils.js" \
|
|
||||||
--output /home/frappe/frappe-bench/apps/frappe/node_utils.js \
|
|
||||||
&& apt-get purge -y curl && apt-get autoremove -y \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
RUN cd /home/frappe/frappe-bench/apps/frappe \
|
RUN cd /home/frappe/frappe-bench/apps/frappe \
|
||||||
&& npm install --only=production \
|
&& npm install --only=production \
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "frappe-socketio",
|
"name": "frappe-socketio",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"description": "Frappe SocketIO Server",
|
"description": "Frappe SocketIO Server",
|
||||||
"main": "socketio.js",
|
"main": "socketio.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -10,8 +10,8 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"redis": "^2.8.0",
|
"redis": "^3.1.1",
|
||||||
"socket.io": "^2.3.0",
|
"socket.io": "^2.4.0",
|
||||||
"superagent": "^5.1.0"
|
"superagent": "^5.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,12 @@ FROM python:3.7-slim-buster
|
|||||||
# Add non root user without password
|
# Add non root user without password
|
||||||
RUN useradd -ms /bin/bash frappe
|
RUN useradd -ms /bin/bash frappe
|
||||||
|
|
||||||
|
ARG GIT_REPO=https://github.com/frappe/frappe
|
||||||
ARG GIT_BRANCH=develop
|
ARG GIT_BRANCH=develop
|
||||||
ARG ARCH=amd64
|
ARG ARCH=amd64
|
||||||
ENV PYTHONUNBUFFERED 1
|
ENV PYTHONUNBUFFERED 1
|
||||||
ENV NVM_DIR=/home/frappe/.nvm
|
ENV NVM_DIR=/home/frappe/.nvm
|
||||||
ENV NODE_VERSION=12.20.0
|
ENV NODE_VERSION=14.17.0
|
||||||
ENV PATH="/home/frappe/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
|
ENV PATH="/home/frappe/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
@ -44,7 +45,7 @@ RUN apt-get update -y && apt-get install \
|
|||||||
&& if [ `uname -m` = 'x86_64' ]; then export ARCH=amd64; fi \
|
&& if [ `uname -m` = 'x86_64' ]; then export ARCH=amd64; fi \
|
||||||
&& wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_${ARCH}.deb \
|
&& wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_${ARCH}.deb \
|
||||||
&& dpkg -i wkhtmltox_0.12.6-1.buster_${ARCH}.deb && rm wkhtmltox_0.12.6-1.buster_${ARCH}.deb \
|
&& dpkg -i wkhtmltox_0.12.6-1.buster_${ARCH}.deb && rm wkhtmltox_0.12.6-1.buster_${ARCH}.deb \
|
||||||
&& wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh \
|
&& wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh \
|
||||||
&& chown -R frappe:frappe /home/frappe
|
&& chown -R frappe:frappe /home/frappe
|
||||||
|
|
||||||
# Setup docker-entrypoint
|
# Setup docker-entrypoint
|
||||||
@ -68,7 +69,7 @@ RUN python -m venv env \
|
|||||||
&& pip3 install --upgrade pip \
|
&& pip3 install --upgrade pip \
|
||||||
&& pip3 install gevent \
|
&& pip3 install gevent \
|
||||||
&& cd apps \
|
&& cd apps \
|
||||||
&& git clone --depth 1 -o upstream https://github.com/frappe/frappe --branch ${GIT_BRANCH} \
|
&& git clone --depth 1 -o upstream ${GIT_REPO} --branch ${GIT_BRANCH} \
|
||||||
&& pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/frappe
|
&& pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/frappe
|
||||||
|
|
||||||
# Copy scripts and templates
|
# Copy scripts and templates
|
||||||
|
5
development/.vscode/launch.json
vendored
5
development/.vscode/launch.json
vendored
@ -12,7 +12,6 @@
|
|||||||
"args": [
|
"args": [
|
||||||
"frappe", "serve", "--port", "8000", "--noreload", "--nothreading"
|
"frappe", "serve", "--port", "8000", "--noreload", "--nothreading"
|
||||||
],
|
],
|
||||||
"pythonPath": "${workspaceFolder}/frappe-bench/env/bin/python",
|
|
||||||
"cwd": "${workspaceFolder}/frappe-bench/sites",
|
"cwd": "${workspaceFolder}/frappe-bench/sites",
|
||||||
"env": {
|
"env": {
|
||||||
"DEV_SERVER": "1"
|
"DEV_SERVER": "1"
|
||||||
@ -26,7 +25,6 @@
|
|||||||
"args": [
|
"args": [
|
||||||
"frappe", "worker", "--queue", "default"
|
"frappe", "worker", "--queue", "default"
|
||||||
],
|
],
|
||||||
"pythonPath": "${workspaceFolder}/frappe-bench/env/bin/python",
|
|
||||||
"cwd": "${workspaceFolder}/frappe-bench/sites",
|
"cwd": "${workspaceFolder}/frappe-bench/sites",
|
||||||
"env": {
|
"env": {
|
||||||
"DEV_SERVER": "1"
|
"DEV_SERVER": "1"
|
||||||
@ -40,7 +38,6 @@
|
|||||||
"args": [
|
"args": [
|
||||||
"frappe", "worker", "--queue", "short"
|
"frappe", "worker", "--queue", "short"
|
||||||
],
|
],
|
||||||
"pythonPath": "${workspaceFolder}/frappe-bench/env/bin/python",
|
|
||||||
"cwd": "${workspaceFolder}/frappe-bench/sites",
|
"cwd": "${workspaceFolder}/frappe-bench/sites",
|
||||||
"env": {
|
"env": {
|
||||||
"DEV_SERVER": "1"
|
"DEV_SERVER": "1"
|
||||||
@ -54,7 +51,6 @@
|
|||||||
"args": [
|
"args": [
|
||||||
"frappe", "worker", "--queue", "long"
|
"frappe", "worker", "--queue", "long"
|
||||||
],
|
],
|
||||||
"pythonPath": "${workspaceFolder}/frappe-bench/env/bin/python",
|
|
||||||
"cwd": "${workspaceFolder}/frappe-bench/sites",
|
"cwd": "${workspaceFolder}/frappe-bench/sites",
|
||||||
"env": {
|
"env": {
|
||||||
"DEV_SERVER": "1"
|
"DEV_SERVER": "1"
|
||||||
@ -64,7 +60,6 @@
|
|||||||
"name": "Honcho SocketIO Watch Schedule Worker",
|
"name": "Honcho SocketIO Watch Schedule Worker",
|
||||||
"type": "python",
|
"type": "python",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"pythonPath": "/usr/bin/python3",
|
|
||||||
"program": "/home/frappe/.local/bin/honcho",
|
"program": "/home/frappe/.local/bin/honcho",
|
||||||
"cwd": "${workspaceFolder}/frappe-bench",
|
"cwd": "${workspaceFolder}/frappe-bench",
|
||||||
"console": "internalConsole",
|
"console": "internalConsole",
|
||||||
|
@ -59,6 +59,7 @@ services:
|
|||||||
- REDIS_SOCKETIO=redis-socketio:6379
|
- REDIS_SOCKETIO=redis-socketio:6379
|
||||||
- SOCKETIO_PORT=9000
|
- SOCKETIO_PORT=9000
|
||||||
- AUTO_MIGRATE=1
|
- AUTO_MIGRATE=1
|
||||||
|
- WORKER_CLASS=${WORKER_CLASS}
|
||||||
volumes:
|
volumes:
|
||||||
- sites-vol:/home/frappe/frappe-bench/sites:rw
|
- sites-vol:/home/frappe/frappe-bench/sites:rw
|
||||||
- assets-vol:/home/frappe/frappe-bench/sites/assets:rw
|
- assets-vol:/home/frappe/frappe-bench/sites/assets:rw
|
||||||
|
@ -15,3 +15,4 @@ HTTPS_REDIRECT_ENTRYPOINT_LABEL=erpnext.local.no-entrypoint
|
|||||||
HTTPS_REDIRECT_MIDDLEWARE_LABEL=erpnext.local.no-middleware
|
HTTPS_REDIRECT_MIDDLEWARE_LABEL=erpnext.local.no-middleware
|
||||||
HTTPS_USE_REDIRECT_MIDDLEWARE_LABEL=erpnext.local-no-redirect-middleware
|
HTTPS_USE_REDIRECT_MIDDLEWARE_LABEL=erpnext.local-no-redirect-middleware
|
||||||
SKIP_NGINX_TEMPLATE_GENERATION=0
|
SKIP_NGINX_TEMPLATE_GENERATION=0
|
||||||
|
WORKER_CLASS=gthread
|
||||||
|
@ -15,3 +15,4 @@ HTTPS_REDIRECT_ENTRYPOINT_LABEL=traefik.http.routers.http-catchall.entrypoints=w
|
|||||||
HTTPS_REDIRECT_MIDDLEWARE_LABEL=traefik.http.routers.http-catchall.middlewares=redirect-to-https
|
HTTPS_REDIRECT_MIDDLEWARE_LABEL=traefik.http.routers.http-catchall.middlewares=redirect-to-https
|
||||||
HTTPS_USE_REDIRECT_MIDDLEWARE_LABEL=traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https
|
HTTPS_USE_REDIRECT_MIDDLEWARE_LABEL=traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https
|
||||||
SKIP_NGINX_TEMPLATE_GENERATION=0
|
SKIP_NGINX_TEMPLATE_GENERATION=0
|
||||||
|
WORKER_CLASS=gthread
|
||||||
|
127
travis.py
127
travis.py
@ -4,37 +4,104 @@ import argparse
|
|||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
|
|
||||||
def parse_args():
|
|
||||||
parser = argparse.ArgumentParser(description='frappe_docker common CI elements', add_help=True)
|
|
||||||
|
|
||||||
parser.add_argument('service', action='store', type=str, help='Name of the service to build: "erpnext" or "frappe"')
|
def parse_args():
|
||||||
parser.add_argument('-o', '--tag-only', required=False, action='store_true', dest='tag_only', help='Only tag an image and push it.')
|
parser = argparse.ArgumentParser(
|
||||||
parser.add_argument('-b', '--is-beta', required=False, default=False, action='store_true', dest='is_beta', help='Specify if tag is beta')
|
description="frappe_docker common CI elements", add_help=True
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"service",
|
||||||
|
action="store",
|
||||||
|
type=str,
|
||||||
|
help='Name of the service to build: "erpnext" or "frappe"',
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-o",
|
||||||
|
"--tag-only",
|
||||||
|
required=False,
|
||||||
|
action="store_true",
|
||||||
|
dest="tag_only",
|
||||||
|
help="Only tag an image and push it.",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-b",
|
||||||
|
"--is-beta",
|
||||||
|
required=False,
|
||||||
|
default=False,
|
||||||
|
action="store_true",
|
||||||
|
dest="is_beta",
|
||||||
|
help="Specify if tag is beta",
|
||||||
|
)
|
||||||
|
|
||||||
image_type = parser.add_mutually_exclusive_group(required=True)
|
image_type = parser.add_mutually_exclusive_group(required=True)
|
||||||
image_type.add_argument('-a', '--nginx', action='store_const', dest='image_type', const='nginx', help='Build the nginx + static assets image')
|
image_type.add_argument(
|
||||||
image_type.add_argument('-s', '--socketio', action='store_const', dest='image_type', const='socketio', help='Build the frappe-socketio image')
|
"-a",
|
||||||
image_type.add_argument('-w', '--worker', action='store_const', dest='image_type', const='worker', help='Build the python environment image')
|
"--nginx",
|
||||||
|
action="store_const",
|
||||||
|
dest="image_type",
|
||||||
|
const="nginx",
|
||||||
|
help="Build the nginx + static assets image",
|
||||||
|
)
|
||||||
|
image_type.add_argument(
|
||||||
|
"-s",
|
||||||
|
"--socketio",
|
||||||
|
action="store_const",
|
||||||
|
dest="image_type",
|
||||||
|
const="socketio",
|
||||||
|
help="Build the frappe-socketio image",
|
||||||
|
)
|
||||||
|
image_type.add_argument(
|
||||||
|
"-w",
|
||||||
|
"--worker",
|
||||||
|
action="store_const",
|
||||||
|
dest="image_type",
|
||||||
|
const="worker",
|
||||||
|
help="Build the python environment image",
|
||||||
|
)
|
||||||
|
|
||||||
tag_type = parser.add_mutually_exclusive_group(required=True)
|
tag_type = parser.add_mutually_exclusive_group(required=True)
|
||||||
tag_type.add_argument('-g', '--git-version', action='store', type=str, dest='version', help='The version number of service (i.e. "11", "12", etc.)')
|
tag_type.add_argument(
|
||||||
tag_type.add_argument('-t', '--tag', action='store', type=str, dest='tag', help='The image tag (i.e. erpnext-worker:$TAG )')
|
"-g",
|
||||||
|
"--git-version",
|
||||||
|
action="store",
|
||||||
|
type=str,
|
||||||
|
dest="version",
|
||||||
|
help='The version number of service (i.e. "11", "12", etc.)',
|
||||||
|
)
|
||||||
|
tag_type.add_argument(
|
||||||
|
"-t",
|
||||||
|
"--tag",
|
||||||
|
action="store",
|
||||||
|
type=str,
|
||||||
|
dest="tag",
|
||||||
|
help="The image tag (i.e. erpnext-worker:$TAG )",
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
||||||
def git_version(service, version, branch, is_beta=False):
|
def git_version(service, version, branch, is_beta=False):
|
||||||
print(f'Pulling {service} v{version}')
|
print(f"Pulling {service} v{version}")
|
||||||
subprocess.run(f'git clone https://github.com/frappe/{service} --branch {branch}', shell=True)
|
subprocess.run(
|
||||||
|
f"git clone https://github.com/frappe/{service} --branch {branch}", shell=True
|
||||||
|
)
|
||||||
cd = os.getcwd()
|
cd = os.getcwd()
|
||||||
os.chdir(os.getcwd() + f'/{service}')
|
os.chdir(os.getcwd() + f"/{service}")
|
||||||
subprocess.run('git fetch --tags', shell=True)
|
subprocess.run("git fetch --tags", shell=True)
|
||||||
|
|
||||||
# XX-beta becomes XX for tags search
|
# XX-beta becomes XX for tags search
|
||||||
version = version.split('-')[0]
|
version = version.split("-")[0]
|
||||||
|
|
||||||
version_tag = subprocess.check_output(f'git tag --list --sort=-version:refname "v{version}*" | sed -n 1p | sed -e \'s#.*@\(\)#\\1#\'', shell=True).strip().decode('ascii')
|
version_tag = (
|
||||||
|
subprocess.check_output(
|
||||||
|
f"git tag --list --sort=-version:refname \"v{version}*\" | sed -n 1p | sed -e 's#.*@\(\)#\\1#'",
|
||||||
|
shell=True,
|
||||||
|
)
|
||||||
|
.strip()
|
||||||
|
.decode("ascii")
|
||||||
|
)
|
||||||
|
|
||||||
if not is_beta:
|
if not is_beta:
|
||||||
version_tag = version_tag.split("-")[0]
|
version_tag = version_tag.split("-")[0]
|
||||||
@ -44,34 +111,40 @@ def git_version(service, version, branch, is_beta=False):
|
|||||||
|
|
||||||
|
|
||||||
def build(service, tag, image, branch):
|
def build(service, tag, image, branch):
|
||||||
build_args = f'--build-arg GIT_BRANCH={branch}'
|
build_args = f"--build-arg GIT_BRANCH={branch}"
|
||||||
if service == 'nginx' and branch == 'version-11':
|
if service == "erpnext":
|
||||||
build_args += f' --build-arg NODE_IMAGE_TAG=10-prod'
|
build_args += f" --build-arg IMAGE_TAG={branch}"
|
||||||
|
if image == "nginx" and branch == "version-11":
|
||||||
|
build_args += f" --build-arg NODE_IMAGE_TAG=10-prod"
|
||||||
|
|
||||||
print(f'Building {service} {image} image')
|
print(f"Building {service} {image} image")
|
||||||
subprocess.run(f'docker build {build_args} -t {service}-{image} -f build/{service}-{image}/Dockerfile .', shell=True)
|
subprocess.run(
|
||||||
tag_and_push(f'{service}-{image}', tag)
|
f"docker build {build_args} -t {service}-{image} -f build/{service}-{image}/Dockerfile .",
|
||||||
|
shell=True,
|
||||||
|
)
|
||||||
|
tag_and_push(f"{service}-{image}", tag)
|
||||||
|
|
||||||
|
|
||||||
def tag_and_push(image_name, tag):
|
def tag_and_push(image_name, tag):
|
||||||
print(f'Tagging {image_name} as "{tag}" and pushing')
|
print(f'Tagging {image_name} as "{tag}" and pushing')
|
||||||
subprocess.run(f'docker tag {image_name} frappe/{image_name}:{tag}', shell=True)
|
subprocess.run(f"docker tag {image_name} frappe/{image_name}:{tag}", shell=True)
|
||||||
subprocess.run(f'docker push frappe/{image_name}:{tag}', shell=True)
|
subprocess.run(f"docker push frappe/{image_name}:{tag}", shell=True)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
tag = args.tag
|
tag = args.tag
|
||||||
branch = 'develop'
|
branch = "develop"
|
||||||
|
|
||||||
if args.version:
|
if args.version:
|
||||||
branch = 'version-' + args.version
|
branch = "version-" + args.version
|
||||||
tag = git_version(args.service, args.version, branch, args.is_beta)
|
tag = git_version(args.service, args.version, branch, args.is_beta)
|
||||||
|
|
||||||
if args.tag_only:
|
if args.tag_only:
|
||||||
tag_and_push(f'{args.service}-{args.image_type}', tag)
|
tag_and_push(f"{args.service}-{args.image_type}", tag)
|
||||||
else:
|
else:
|
||||||
build(args.service, tag, args.image_type, branch)
|
build(args.service, tag, args.image_type, branch)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user