-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
175 lines (146 loc) · 5.27 KB
/
Dockerfile
File metadata and controls
175 lines (146 loc) · 5.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# syntax=docker/dockerfile:1
###############################################
# ERPNext image - single multi-stage source
# -
# Three chained stages, each published as its own tag:
# base -> version-16-latest
# all-in-one -> ALL-version-16-latest
# pre-install -> PRE-version-16-latest
#
# Build a specific tag with --target, e.g.:
# docker buildx build --target base -t repo:version-16-latest .
# docker buildx build --target all-in-one -t repo:ALL-version-16-latest .
# docker buildx build --target pre-install -t repo:PRE-version-16-latest .
#
# More info on the base image:
# https://spacecode.co.th/knowledge-base/p/erpnext-docker
###############################################
###############################################
# Stage 1: base
# -
# Bench + ERPNext bundled on top of frappe/build.
###############################################
FROM frappe/build:version-16 AS base
###############################################
# Adding Dependencies
###############################################
USER root
RUN apt-get update \
# [Hotfix]: https://github.com/moby/moby/issues/27988
&& DEBIAN_FRONTEND=noninteractive \
apt-get install -y -q \
# Adding sudo
sudo \
&& echo "frappe ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
# Cleanup install
&& apt-get autoremove --purge -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/*
###############################################
# Init Bench
# -
# (copied from builder section of production image)
# https://github.com/frappe/frappe_docker/blob/d1289a860493df9726938535f5e26088e4f83496/images/production/Containerfile#L115-L126
###############################################
USER frappe
ARG FRAPPE_REPO=https://github.com/frappe/frappe
ARG FRAPPE_BRANCH=version-16
ARG ERPNEXT_REPO=https://github.com/frappe/erpnext
ARG ERPNEXT_BRANCH=version-16
RUN bench init \
--frappe-branch=${FRAPPE_BRANCH} \
--frappe-path=${FRAPPE_REPO} \
--no-backups \
--skip-redis-config-generation \
--verbose \
/home/frappe/frappe-bench && \
cd /home/frappe/frappe-bench && \
bench get-app --branch=${ERPNEXT_BRANCH} --resolve-deps erpnext ${ERPNEXT_REPO} && \
echo "{}" > sites/common_site_config.json
###############################################
# FINALIZED
###############################################
WORKDIR /home/frappe/frappe-bench
USER frappe
###############################################
# Stage 2: all-in-one
# -
# Could be used for
# * Quick trial setup
# * Railway setup (Sleep-able)
# * Dokploy preview deployment
#
# Add services missing from the base. These are
# services that usually run in external containers:
# * Supervisor
# * Nginx
# * Redis
# * MariaDB
###############################################
FROM base AS all-in-one
USER root
RUN apt-get update \
# [Hotfix]: https://github.com/moby/moby/issues/27988
&& DEBIAN_FRONTEND=noninteractive \
apt-get install -y --no-install-recommends \
nginx \
redis-server \
supervisor \
gettext-base \
&& curl -LsSO https://downloads.mariadb.com/MariaDB/mariadb_repo_setup \
&& bash mariadb_repo_setup --mariadb-server-version="mariadb-11.8" \
&& rm mariadb_repo_setup \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
mariadb-server \
mariadb-client \
&& rm -rf /var/lib/apt/lists/*
###############################################
# COPY FILES
###############################################
COPY --chown=frappe:frappe --chmod=0755 ./all-in-one/conf/setup.sh /usr/local/bin/setup.sh
COPY --chown=frappe:frappe ./all-in-one/conf/supervisord.conf /etc/supervisor/conf.d/frappe.conf
COPY --chown=frappe:frappe ./all-in-one/conf/nginx.conf /etc/nginx/frappe.conf.template
###############################################
# Stage 3: pre-install
# -
# Same batteries as the all-in-one image, but the
# site is created and ERPNext is installed at BUILD
# time (see pre-install/conf/init.sh) instead of on
# first boot.
#
# The container therefore starts straight into a
# ready-to-use site - nginx, supervisor, MariaDB,
# Redis and all the frappe processes - with no
# lengthy first-run setup.
###############################################
FROM all-in-one AS pre-install
USER root
###############################################
# Build-time site configuration
# -
# Override with --build-arg to change the baked-in
# site name / credentials.
###############################################
ARG SITE_NAME=default.site
ARG ADMIN_PASSWORD=admin
ARG DB_ROOT_PASSWORD=admin
# Persist the site name so the runtime entrypoint
# can inject it into the nginx config.
ENV SITE_NAME=${SITE_NAME}
###############################################
# COPY FILES
###############################################
COPY --chown=frappe:frappe --chmod=0755 ./pre-install/conf/init.sh /usr/local/bin/init.sh
COPY --chown=frappe:frappe --chmod=0755 ./pre-install/conf/start.sh /usr/local/bin/start.sh
###############################################
# Pre-install: create the site + install ERPNext
# at build time and bake it into the image.
###############################################
RUN SITE_NAME="${SITE_NAME}" \
ADMIN_PASSWORD="${ADMIN_PASSWORD}" \
DB_ROOT_PASSWORD="${DB_ROOT_PASSWORD}" \
/usr/local/bin/init.sh
EXPOSE 80
CMD ["/usr/local/bin/start.sh"]