2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-12-23 10:38:58 +00:00

Merge pull request #289 from revant/reuse-dockerfile

This commit is contained in:
Chinmay Pai 2020-06-28 13:03:32 +05:30 committed by GitHub
commit 38f5f430c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 131 additions and 550 deletions

View File

@ -1,10 +1,13 @@
FROM bitnami/node:12-prod
ARG NODE_IMAGE_TAG=12-prod
ARG GIT_BRANCH=develop
FROM bitnami/node:${NODE_IMAGE_TAG}
ARG GIT_BRANCH
COPY build/erpnext-nginx/install_app.sh /install_app
RUN /install_app erpnext https://github.com/frappe/erpnext
RUN /install_app erpnext https://github.com/frappe/erpnext ${GIT_BRANCH}
FROM frappe/frappe-nginx:develop
FROM frappe/frappe-nginx:${GIT_BRANCH}
COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/
COPY --from=0 /rsync /rsync

View File

@ -1,16 +0,0 @@
FROM bitnami/node:10-prod
COPY build/erpnext-nginx/install_app.sh /install_app
RUN /install_app erpnext https://github.com/frappe/erpnext version-11
FROM frappe/frappe-nginx:v11
COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/
COPY --from=0 /rsync /rsync
RUN echo -n "\nerpnext" >> /var/www/html/apps.txt
VOLUME [ "/assets" ]
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]

View File

@ -1,16 +0,0 @@
FROM bitnami/node:12-prod
COPY build/erpnext-nginx/install_app.sh /install_app
RUN /install_app erpnext https://github.com/frappe/erpnext version-12
FROM frappe/frappe-nginx:v12
COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/
COPY --from=0 /rsync /rsync
RUN echo -n "\nerpnext" >> /var/www/html/apps.txt
VOLUME [ "/assets" ]
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]

View File

@ -1,16 +0,0 @@
FROM bitnami/node:12-prod
COPY build/erpnext-nginx/install_app.sh /install_app
RUN /install_app erpnext https://github.com/frappe/erpnext version-13-beta
FROM frappe/frappe-nginx:v13-beta
COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/
COPY --from=0 /rsync /rsync
RUN echo -n "\nerpnext" >> /var/www/html/apps.txt
VOLUME [ "/assets" ]
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]

View File

@ -1,3 +1,5 @@
FROM frappe/frappe-worker:develop
ARG GIT_BRANCH=develop
FROM frappe/frappe-worker:${GIT_BRANCH}
RUN install_app erpnext https://github.com/frappe/erpnext
ARG GIT_BRANCH
RUN install_app erpnext https://github.com/frappe/erpnext ${GIT_BRANCH}

View File

@ -1,3 +0,0 @@
FROM frappe/frappe-worker:v11
RUN install_app erpnext https://github.com/frappe/erpnext version-11

View File

@ -1,3 +0,0 @@
FROM frappe/frappe-worker:v12
RUN install_app erpnext https://github.com/frappe/erpnext version-12

View File

@ -1,3 +0,0 @@
FROM frappe/frappe-worker:v13-beta
RUN install_app erpnext https://github.com/frappe/erpnext version-13-beta

View File

@ -1,4 +1,5 @@
FROM bitnami/node:12-prod
ARG NODE_IMAGE_TAG=12-prod
FROM bitnami/node:${NODE_IMAGE_TAG}
WORKDIR /home/frappe/frappe-bench
RUN mkdir -p /home/frappe/frappe-bench/sites \
@ -6,26 +7,17 @@ RUN mkdir -p /home/frappe/frappe-bench/sites \
RUN install_packages git
ARG GIT_BRANCH=develop
RUN mkdir -p apps sites/assets/css \
&& cd apps \
&& git clone --depth 1 https://github.com/frappe/frappe
&& git clone --depth 1 https://github.com/frappe/frappe --branch $GIT_BRANCH
COPY build/frappe-nginx/generate_standard_style_css.js \
/home/frappe/frappe-bench/apps/frappe/generate_standard_style_css.js
RUN cd /home/frappe/frappe-bench/apps/frappe \
&& yarn \
&& yarn run production \
&& yarn add nunjucks -D \
&& node generate_standard_style_css.js \
frappe/website/doctype/website_theme/website_theme_template.scss > \
/home/frappe/standard_templates_string \
&& node generate_bootstrap_theme.js \
/home/frappe/frappe-bench/sites/assets/css/standard_style.css \
"$(cat /home/frappe/standard_templates_string)" \
&& rm -fr node_modules \
&& yarn install --production=true \
&& node --version \
COPY build/frappe-nginx/build.sh /build.sh
RUN /build.sh
RUN node --version \
&& npm --version \
&& yarn --version

23
build/frappe-nginx/build.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
function nodeCleanUp() {
rm -fr node_modules
yarn install --production=true
}
cd /home/frappe/frappe-bench/apps/frappe
yarn
yarn run production
yarn add nunjucks -D
if [[ "$GIT_BRANCH" =~ ^(version-12|version-11)$ ]]; then
nodeCleanUp
else
node generate_standard_style_css.js \
frappe/website/doctype/website_theme/website_theme_template.scss > \
/home/frappe/standard_templates_string
node generate_bootstrap_theme.js \
/home/frappe/frappe-bench/sites/assets/css/standard_style.css \
"$(cat /home/frappe/standard_templates_string)"
nodeCleanUp
fi

View File

@ -1,42 +0,0 @@
FROM bitnami/node:10-prod
WORKDIR /home/frappe/frappe-bench
RUN mkdir -p /home/frappe/frappe-bench/sites \
&& echo "frappe" > /home/frappe/frappe-bench/sites/apps.txt
RUN install_packages git
RUN mkdir -p apps sites/assets \
&& cd apps \
&& git clone --depth 1 https://github.com/frappe/frappe --branch version-11
RUN cd /home/frappe/frappe-bench/apps/frappe \
&& yarn \
&& yarn run production \
&& rm -fr node_modules \
&& yarn install --production=true \
&& node --version \
&& npm --version \
&& yarn --version
RUN git clone --depth 1 https://github.com/frappe/bench /tmp/bench \
&& mkdir -p /var/www/error_pages \
&& cp -r /tmp/bench/bench/config/templates /var/www/error_pages
RUN cp -R /home/frappe/frappe-bench/apps/frappe/frappe/public/* /home/frappe/frappe-bench/sites/assets/frappe \
&& cp -R /home/frappe/frappe-bench/apps/frappe/node_modules /home/frappe/frappe-bench/sites/assets/frappe/
FROM nginx:latest
COPY --from=0 /home/frappe/frappe-bench/sites /var/www/html/
COPY --from=0 /var/www/error_pages /var/www/
COPY build/common/nginx-default.conf.template /etc/nginx/conf.d/default.conf.template
COPY build/frappe-nginx/docker-entrypoint.sh /
RUN apt-get update && apt-get install -y rsync && apt-get clean \
&& echo "#!/bin/bash" > /rsync \
&& chmod +x /rsync
VOLUME [ "/assets" ]
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]

View File

@ -1,42 +0,0 @@
FROM bitnami/node:12-prod
WORKDIR /home/frappe/frappe-bench
RUN mkdir -p /home/frappe/frappe-bench/sites \
&& echo "frappe" > /home/frappe/frappe-bench/sites/apps.txt
RUN install_packages git
RUN mkdir -p apps sites/assets \
&& cd apps \
&& git clone --depth 1 https://github.com/frappe/frappe --branch version-12
RUN cd /home/frappe/frappe-bench/apps/frappe \
&& yarn \
&& yarn run production \
&& rm -fr node_modules \
&& yarn install --production=true \
&& node --version \
&& npm --version \
&& yarn --version
RUN git clone --depth 1 https://github.com/frappe/bench /tmp/bench \
&& mkdir -p /var/www/error_pages \
&& cp -r /tmp/bench/bench/config/templates /var/www/error_pages
RUN cp -R /home/frappe/frappe-bench/apps/frappe/frappe/public/* /home/frappe/frappe-bench/sites/assets/frappe \
&& cp -R /home/frappe/frappe-bench/apps/frappe/node_modules /home/frappe/frappe-bench/sites/assets/frappe/
FROM nginx:latest
COPY --from=0 /home/frappe/frappe-bench/sites /var/www/html/
COPY --from=0 /var/www/error_pages /var/www/
COPY build/common/nginx-default.conf.template /etc/nginx/conf.d/default.conf.template
COPY build/frappe-nginx/docker-entrypoint.sh /
RUN apt-get update && apt-get install -y rsync && apt-get clean \
&& echo "#!/bin/bash" > /rsync \
&& chmod +x /rsync
VOLUME [ "/assets" ]
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]

View File

@ -1,52 +0,0 @@
FROM bitnami/node:12-prod
WORKDIR /home/frappe/frappe-bench
RUN mkdir -p /home/frappe/frappe-bench/sites \
&& echo "frappe" > /home/frappe/frappe-bench/sites/apps.txt
RUN install_packages git
RUN mkdir -p apps sites/assets/css \
&& cd apps \
&& git clone --depth 1 https://github.com/frappe/frappe --branch version-13-beta
COPY build/frappe-nginx/generate_standard_style_css.js \
/home/frappe/frappe-bench/apps/frappe/generate_standard_style_css.js
RUN cd /home/frappe/frappe-bench/apps/frappe \
&& yarn \
&& yarn run production \
&& yarn add nunjucks -D \
&& node generate_standard_style_css.js \
frappe/website/doctype/website_theme/website_theme_template.scss > \
/home/frappe/standard_templates_string \
&& node generate_bootstrap_theme.js \
/home/frappe/frappe-bench/sites/assets/css/standard_style.css \
"$(cat /home/frappe/standard_templates_string)" \
&& rm -fr node_modules \
&& yarn install --production=true \
&& node --version \
&& npm --version \
&& yarn --version
RUN git clone --depth 1 https://github.com/frappe/bench /tmp/bench \
&& mkdir -p /var/www/error_pages \
&& cp -r /tmp/bench/bench/config/templates /var/www/error_pages
RUN cp -R /home/frappe/frappe-bench/apps/frappe/frappe/public/* /home/frappe/frappe-bench/sites/assets/frappe \
&& cp -R /home/frappe/frappe-bench/apps/frappe/node_modules /home/frappe/frappe-bench/sites/assets/frappe/
FROM nginx:latest
COPY --from=0 /home/frappe/frappe-bench/sites /var/www/html/
COPY --from=0 /var/www/error_pages /var/www/
COPY build/common/nginx-default.conf.template /etc/nginx/conf.d/default.conf.template
COPY build/frappe-nginx/docker-entrypoint.sh /
RUN apt-get update && apt-get install -y rsync && apt-get clean \
&& echo "#!/bin/bash" > /rsync \
&& chmod +x /rsync
VOLUME [ "/assets" ]
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]

View File

@ -1,31 +1,29 @@
FROM node:slim
# Install needed packages
RUN apt-get update && apt-get install -y curl && apt-get clean
# Add frappe user
RUN useradd -ms /bin/bash frappe
# Make bench directories
RUN mkdir -p /home/frappe/frappe-bench/sites /home/frappe/frappe-bench/apps/frappe
# Create bench directories and set ownership
RUN mkdir -p /home/frappe/frappe-bench/sites /home/frappe/frappe-bench/apps/frappe \
&& chown -R frappe:frappe /home/frappe
# Download socketio and purge curl package
COPY build/frappe-socketio/package.json /home/frappe/frappe-bench/apps/frappe
# get socketio
RUN cd /home/frappe/frappe-bench/apps/frappe \
&& curl https://raw.githubusercontent.com/frappe/frappe/develop/socketio.js \
ARG GIT_BRANCH=develop
RUN apt-get update && apt-get install -y curl \
&& 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/develop/node_utils.js \
--output /home/frappe/frappe-bench/apps/frappe/node_utils.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 \
&& npm install --only=production \
&& node --version \
&& npm --version
COPY build/frappe-socketio/health.js /home/frappe/frappe-bench/apps/frappe/health.js
RUN chown -R frappe:frappe /home/frappe
# Setup docker-entrypoint
COPY build/frappe-socketio/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat

View File

@ -1,19 +0,0 @@
var net = require('net');
var { get_conf } = require('./node_utils');
var conf = get_conf();
var server = ['localhost', conf.socketio_port || 9000];
var sock = new net.Socket();
sock.setTimeout(2500);
sock.on('connect', function() {
console.info(server[0]+':'+server[1]+' is up.');
sock.destroy();
process.exit();
}).on('error', function(e) {
console.error(server[0]+':'+server[1]+' is down: ' + e.message);
process.exit(1);
}).on('timeout', function(e) {
console.error(server[0]+':'+server[1]+' is down: timeout');
process.exit(1);
}).connect(server[1], server[0]);

View File

@ -1,36 +0,0 @@
FROM node:slim
# Install needed packages
RUN apt-get update && apt-get install -y curl && apt-get clean
RUN useradd -ms /bin/bash frappe
# Make bench directories
RUN mkdir -p /home/frappe/frappe-bench/sites /home/frappe/frappe-bench/apps/frappe
COPY build/frappe-socketio/package.json /home/frappe/frappe-bench/apps/frappe
# get socketio
RUN cd /home/frappe/frappe-bench/apps/frappe \
&& curl https://raw.githubusercontent.com/frappe/frappe/version-11/socketio.js \
--output /home/frappe/frappe-bench/apps/frappe/socketio.js \
&& curl https://raw.githubusercontent.com/frappe/frappe/version-11/node_utils.js \
--output /home/frappe/frappe-bench/apps/frappe/node_utils.js
RUN cd /home/frappe/frappe-bench/apps/frappe \
&& npm install --only=production \
&& node --version \
&& npm --version
COPY build/frappe-socketio/health.js /home/frappe/frappe-bench/apps/frappe/health.js
RUN chown -R frappe:frappe /home/frappe
# Setup docker-entrypoint
COPY build/frappe-socketio/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat
WORKDIR /home/frappe/frappe-bench/sites
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["start"]

View File

@ -1,36 +0,0 @@
FROM node:slim
# Install needed packages
RUN apt-get update && apt-get install -y curl && apt-get clean
RUN useradd -ms /bin/bash frappe
# Make bench directories
RUN mkdir -p /home/frappe/frappe-bench/sites /home/frappe/frappe-bench/apps/frappe
COPY build/frappe-socketio/package.json /home/frappe/frappe-bench/apps/frappe
# get socketio
RUN cd /home/frappe/frappe-bench/apps/frappe \
&& curl https://raw.githubusercontent.com/frappe/frappe/version-12/socketio.js \
--output /home/frappe/frappe-bench/apps/frappe/socketio.js \
&& curl https://raw.githubusercontent.com/frappe/frappe/version-12/node_utils.js \
--output /home/frappe/frappe-bench/apps/frappe/node_utils.js
RUN cd /home/frappe/frappe-bench/apps/frappe \
&& npm install --only=production \
&& node --version \
&& npm --version
COPY build/frappe-socketio/health.js /home/frappe/frappe-bench/apps/frappe/health.js
RUN chown -R frappe:frappe /home/frappe
# Setup docker-entrypoint
COPY build/frappe-socketio/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat
WORKDIR /home/frappe/frappe-bench/sites
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["start"]

View File

@ -1,36 +0,0 @@
FROM node:slim
# Install needed packages
RUN apt-get update && apt-get install -y curl && apt-get clean
RUN useradd -ms /bin/bash frappe
# Make bench directories
RUN mkdir -p /home/frappe/frappe-bench/sites /home/frappe/frappe-bench/apps/frappe
COPY build/frappe-socketio/package.json /home/frappe/frappe-bench/apps/frappe
# get socketio
RUN cd /home/frappe/frappe-bench/apps/frappe \
&& curl https://raw.githubusercontent.com/frappe/frappe/version-13-beta/socketio.js \
--output /home/frappe/frappe-bench/apps/frappe/socketio.js \
&& curl https://raw.githubusercontent.com/frappe/frappe/version-13-beta/node_utils.js \
--output /home/frappe/frappe-bench/apps/frappe/node_utils.js
RUN cd /home/frappe/frappe-bench/apps/frappe \
&& npm install --only=production \
&& node --version \
&& npm --version
COPY build/frappe-socketio/health.js /home/frappe/frappe-bench/apps/frappe/health.js
RUN chown -R frappe:frappe /home/frappe
# Setup docker-entrypoint
COPY build/frappe-socketio/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat
WORKDIR /home/frappe/frappe-bench/sites
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["start"]

View File

@ -1,45 +1,57 @@
FROM bitnami/python:latest-prod
FROM bitnami/python:3.7-prod
RUN useradd -ms /bin/bash frappe
ARG GIT_BRANCH=develop
ENV PYTHONUNBUFFERED 1
# Install dependencies
WORKDIR /home/frappe/frappe-bench
RUN install_packages \
git \
wkhtmltopdf \
mariadb-client \
postgresql-client \
gettext-base \
wget \
# for PDF
libjpeg62-turbo \
libx11-6 \
libxcb1 \
libxext6 \
libxrender1 \
libssl-dev \
fonts-cantarell \
xfonts-75dpi \
xfonts-base \
# For psycopg2
libpq-dev \
build-essential
# Install wkhtmltox correctly
RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.buster_amd64.deb
RUN dpkg -i wkhtmltox_0.12.5-1.buster_amd64.deb && rm wkhtmltox_0.12.5-1.buster_amd64.deb
&& wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.buster_amd64.deb \
&& dpkg -i wkhtmltox_0.12.5-1.buster_amd64.deb && rm wkhtmltox_0.12.5-1.buster_amd64.deb \
&& apt-get purge -y wget && apt-get autoremove -y
# Create frappe-bench directories
RUN mkdir -p apps logs commands /home/frappe/backups
RUN virtualenv env \
# Setup python environment
RUN python -m venv env \
&& . env/bin/activate \
&& cd apps \
&& git clone --depth 1 -o upstream https://github.com/frappe/frappe \
&& git clone --depth 1 -o upstream https://github.com/frappe/frappe --branch ${GIT_BRANCH} \
&& pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/frappe
# Copy scripts and templates
COPY build/common/commands/* /home/frappe/frappe-bench/commands/
COPY build/common/common_site_config.json.template /opt/frappe/common_site_config.json.template
COPY build/common/worker/install_app.sh /usr/local/bin/install_app
# Setup docker-entrypoint
COPY build/common/worker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat
COPY build/common/worker/install_app.sh /usr/local/bin/install_app
# Use sites volume as working directory
WORKDIR /home/frappe/frappe-bench/sites
# Set ownership of sites directory
RUN chown -R frappe:frappe /home/frappe/frappe-bench/sites /home/frappe/backups
VOLUME [ "/home/frappe/frappe-bench/sites", "/home/frappe/backups" ]

View File

@ -1,45 +0,0 @@
FROM bitnami/python:latest-prod
RUN useradd -ms /bin/bash frappe
WORKDIR /home/frappe/frappe-bench
RUN install_packages \
git \
wkhtmltopdf \
mariadb-client \
gettext-base \
wget \
# for PDF
libssl-dev \
fonts-cantarell \
xfonts-75dpi \
xfonts-base
# Install wkhtmltox correctly
RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.buster_amd64.deb
RUN dpkg -i wkhtmltox_0.12.5-1.buster_amd64.deb && rm wkhtmltox_0.12.5-1.buster_amd64.deb
RUN mkdir -p apps logs commands /home/frappe/backups
RUN virtualenv env \
&& . env/bin/activate \
&& cd apps \
&& git clone --depth 1 -o upstream https://github.com/frappe/frappe --branch version-11 \
&& pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/frappe
COPY build/common/commands/* /home/frappe/frappe-bench/commands/
COPY build/common/common_site_config.json.template /opt/frappe/common_site_config.json.template
# Setup docker-entrypoint
COPY build/common/worker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat
COPY build/common/worker/install_app.sh /usr/local/bin/install_app
WORKDIR /home/frappe/frappe-bench/sites
RUN chown -R frappe:frappe /home/frappe/frappe-bench/sites /home/frappe/backups
VOLUME [ "/home/frappe/frappe-bench/sites", "/home/frappe/backups" ]
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["start"]

View File

@ -1,48 +0,0 @@
FROM bitnami/python:latest-prod
RUN useradd -ms /bin/bash frappe
WORKDIR /home/frappe/frappe-bench
RUN install_packages \
git \
wkhtmltopdf \
mariadb-client \
gettext-base \
wget \
# for PDF
libssl-dev \
fonts-cantarell \
xfonts-75dpi \
xfonts-base \
# For psycopg2
libpq-dev \
build-essential
# Install wkhtmltox correctly
RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.buster_amd64.deb
RUN dpkg -i wkhtmltox_0.12.5-1.buster_amd64.deb && rm wkhtmltox_0.12.5-1.buster_amd64.deb
RUN mkdir -p apps logs commands /home/frappe/backups
RUN virtualenv env \
&& . env/bin/activate \
&& cd apps \
&& git clone --depth 1 -o upstream https://github.com/frappe/frappe --branch version-12 \
&& pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/frappe
COPY build/common/commands/* /home/frappe/frappe-bench/commands/
COPY build/common/common_site_config.json.template /opt/frappe/common_site_config.json.template
# Setup docker-entrypoint
COPY build/common/worker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat
COPY build/common/worker/install_app.sh /usr/local/bin/install_app
WORKDIR /home/frappe/frappe-bench/sites
RUN chown -R frappe:frappe /home/frappe/frappe-bench/sites /home/frappe/backups
VOLUME [ "/home/frappe/frappe-bench/sites", "/home/frappe/backups" ]
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["start"]

View File

@ -1,48 +0,0 @@
FROM bitnami/python:latest-prod
RUN useradd -ms /bin/bash frappe
WORKDIR /home/frappe/frappe-bench
RUN install_packages \
git \
wkhtmltopdf \
mariadb-client \
gettext-base \
wget \
# for PDF
libssl-dev \
fonts-cantarell \
xfonts-75dpi \
xfonts-base \
# For psycopg2
libpq-dev \
build-essential
# Install wkhtmltox correctly
RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.buster_amd64.deb
RUN dpkg -i wkhtmltox_0.12.5-1.buster_amd64.deb && rm wkhtmltox_0.12.5-1.buster_amd64.deb
RUN mkdir -p apps logs commands /home/frappe/backups
RUN virtualenv env \
&& . env/bin/activate \
&& cd apps \
&& git clone --depth 1 -o upstream https://github.com/frappe/frappe --branch version-13-beta \
&& pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/frappe
COPY build/common/commands/* /home/frappe/frappe-bench/commands/
COPY build/common/common_site_config.json.template /opt/frappe/common_site_config.json.template
# Setup docker-entrypoint
COPY build/common/worker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat
COPY build/common/worker/install_app.sh /usr/local/bin/install_app
WORKDIR /home/frappe/frappe-bench/sites
RUN chown -R frappe:frappe /home/frappe/frappe-bench/sites /home/frappe/backups
VOLUME [ "/home/frappe/frappe-bench/sites", "/home/frappe/backups" ]
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["start"]

View File

@ -1,7 +1,7 @@
#!/bin/bash
function checkMigrationComplete() {
echo "Check Auto Migration"
echo "Check Migration"
CONTAINER_ID=$(docker-compose \
--project-name frappebench00 \
-f installation/docker-compose-common.yml \
@ -21,6 +21,9 @@ function checkMigrationComplete() {
exit 1
fi
done
echo -e "\e[4mMigration Log\e[0m"
docker logs $CONTAINER_ID
}
function loopHealthCheck() {

View File

@ -4,60 +4,69 @@ import argparse
import subprocess
import os
parser = argparse.ArgumentParser(description='frappe_docker common CI elements', add_help=True)
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"')
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('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.')
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('-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')
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('-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.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('-t', '--tag', action='store', type=str, dest='tag', help='The image tag (i.e. erpnext-worker:$TAG )')
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('-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
def git_version(service, version):
print(f'Pulling {service} v{version}')
subprocess.run(f'git clone https://github.com/frappe/{service} --branch version-{version}', shell=True)
cd = os.getcwd()
os.chdir(os.getcwd() + f'/{service}')
subprocess.run('git fetch --tags', shell=True)
# XX-beta becomes XX for tags search
version = version.split('-')[0]
def git_version(service, version, branch):
print(f'Pulling {service} v{version}')
subprocess.run(f'git clone https://github.com/frappe/{service} --branch {branch}', shell=True)
cd = os.getcwd()
os.chdir(os.getcwd() + f'/{service}')
subprocess.run('git fetch --tags', shell=True)
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')
os.chdir(cd)
return version_tag
# XX-beta becomes XX for tags search
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')
os.chdir(cd)
return version_tag
def build(service, tag, image, branch):
build_args = f'--build-arg GIT_BRANCH={branch}'
if service == 'nginx' and branch == 'version-11':
build_args += f' --build-arg NODE_IMAGE_TAG=10-prod'
print(f'Building {service} {image} image')
subprocess.run(f'docker build {build_args} -t {service}-{image} -f build/{service}-{image}/Dockerfile .', shell=True)
tag_and_push(f'{service}-{image}', tag)
def build(service, tag, image, dockerfile):
print(f'Building {service} {image} image using {dockerfile}')
subprocess.run(f'docker build -t {service}-{image} -f build/{service}-{image}/{dockerfile} .', shell=True)
tag_and_push(f'{service}-{image}', tag)
def tag_and_push(image_name, tag):
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 push frappe/{image_name}:{tag}', shell=True)
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 push frappe/{image_name}:{tag}', shell=True)
def main():
global tag
global dockerfile
if args.version:
tag = git_version(args.service, args.version)
dockerfile = f'v{args.version}.Dockerfile'
else:
args = parse_args()
tag = args.tag
dockerfile = 'Dockerfile'
branch = 'develop'
if args.tag_only:
tag_and_push(f'{args.service}-{args.image_type}', tag)
else:
build(args.service, tag, args.image_type, dockerfile)
if args.version:
branch = 'version-' + args.version
tag = git_version(args.service, args.version, branch)
main()
if args.tag_only:
tag_and_push(f'{args.service}-{args.image_type}', tag)
else:
build(args.service, tag, args.image_type, branch)
if __name__ == "__main__":
main()