Skip to content

Commit c9fb4fc

Browse files
committed
Move setup logic from Dockerfile into entrypoint.sh
1 parent 332f862 commit c9fb4fc

2 files changed

Lines changed: 33 additions & 9 deletions

File tree

Dockerfile

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,12 @@ FROM php:7.4-apache
1010

1111
COPY lib/ /var/www/lib/
1212
COPY html/ /var/www/html/
13+
1314
COPY --from=builder /app/simplycode-electron/simplycode/ /var/www/html/simplycode/
1415
COPY --from=builder /app/simplyedit-backend/www/ /var/www/www/
1516

16-
RUN a2enmod --quiet rewrite ssl headers \
17-
&& ln -s /var/www/html/simplycode/js/ /var/www/html/js \
18-
&& ln -s /var/www/www/api/data/generated.html /var/www/html/index.html \
19-
&& ln -s /var/www/www/api/data/generated.html /var/www/html/index.js \
20-
&& mv /var/www/lib/000-default.conf /etc/apache2/sites-available/000-default.conf \
21-
&& mv /var/www/lib/403.php /var/www/html/403.php \
22-
&& mv /var/www/lib/server.key /etc/ssl/private/ssl-cert-snakeoil.key \
23-
&& mv /var/www/lib/server.pem /etc/ssl/certs/ssl-cert-snakeoil.pem \
24-
&& chmod +x /entrypoint.sh \
17+
RUN echo "ServerName simplycode" >> /etc/apache2/apache2.conf \
18+
&& a2enmod --quiet rewrite ssl headers \
19+
&& chmod +x /var/www/lib/entrypoint.sh
2520

2621
ENTRYPOINT ["/var/www/lib/entrypoint.sh"]

lib/entrypoint.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ entrypoint() {
6464
if [ -n "${subject}" ] && [ -n "$(command -v "${subject}" 2> /dev/null)" ]; then
6565
exec "${@}"
6666
else
67+
runSetup
6768
runChecks
6869

6970
if [ -d /var/www/html/assets ]; then
@@ -130,4 +131,32 @@ runChecks() {
130131
fi
131132
}
132133

134+
runSetup() {
135+
if [ ! -f /var/www/html/index.html ]; then
136+
printf '%sFirst initialisation. Running setup...%s\n' \
137+
"$(tput setaf 7)$(tput setab 6)" \
138+
"$(tput sgr 0)"
139+
140+
(
141+
PS4="$(echo -e " ")"
142+
set -x
143+
ln -s /var/www/html/simplycode/js/ /var/www/html/js
144+
ln -s /var/www/www/api/data/generated.html /var/www/html/index.html
145+
ln -s /var/www/www/api/data/generated.html /var/www/html/index.js
146+
147+
mkdir -p /var/www/html/simply/ \
148+
&& ln -s /var/www/html/simplycode/simply/databind.js /var/www/html/simply/databind.js
149+
150+
mv /var/www/lib/000-default.conf /etc/apache2/sites-available/000-default.conf
151+
mv /var/www/lib/403.php /var/www/html/403.php
152+
mv /var/www/lib/server.key /etc/ssl/private/ssl-cert-snakeoil.key
153+
mv /var/www/lib/server.pem /etc/ssl/certs/ssl-cert-snakeoil.pem
154+
)
155+
156+
printf '%sSetup complete%s\n\n' \
157+
"$(tput setaf 7)$(tput setab 6)" \
158+
"$(tput sgr 0)"
159+
fi
160+
}
161+
133162
entrypoint "$@"

0 commit comments

Comments
 (0)