Skip to content

Commit 328e8f1

Browse files
author
Tobias Stein
committed
Add separate docker file for linux 16.04
Enable dynamic path with environment variable which triggers node js build at container runtime
1 parent b0ece06 commit 328e8f1

File tree

5 files changed

+146
-20
lines changed

5 files changed

+146
-20
lines changed

Dockerfile

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@
44
# base system
55
################################################################################
66

7-
FROM ubuntu:18.04 as system
8-
9-
7+
FROM ubuntu:16.04 as system
108

119
RUN sed -i 's#http://archive.ubuntu.com/#http://tw.archive.ubuntu.com/#' /etc/apt/sources.list;
1210

13-
1411
# built-in packages
1512
ENV DEBIAN_FRONTEND noninteractive
1613
RUN apt update \
@@ -27,7 +24,7 @@ RUN apt update \
2724
RUN add-apt-repository -y ppa:fcwu-tw/apps \
2825
&& apt update \
2926
&& apt install -y --no-install-recommends --allow-unauthenticated \
30-
xvfb x11vnc=0.9.16-1 \
27+
xvfb x11vnc\
3128
vim-tiny firefox chromium-browser ttf-ubuntu-font-family ttf-wqy-zenhei \
3229
&& add-apt-repository -r ppa:fcwu-tw/apps \
3330
&& apt autoclean -y \
@@ -36,7 +33,7 @@ RUN add-apt-repository -y ppa:fcwu-tw/apps \
3633

3734
RUN apt update \
3835
&& apt install -y --no-install-recommends --allow-unauthenticated \
39-
lxde gtk2-engines-murrine gnome-themes-standard gtk2-engines-pixbuf gtk2-engines-murrine arc-theme \
36+
lxde gtk2-engines-murrine gnome-themes-standard gtk2-engines-pixbuf gtk2-engines-murrine \
4037
&& apt autoclean -y \
4138
&& apt autoremove -y \
4239
&& rm -rf /var/lib/apt/lists/*
@@ -77,10 +74,6 @@ RUN apt-get update \
7774
################################################################################
7875
# FROM ubuntu:18.04 as builder
7976

80-
81-
RUN sed -i 's#http://archive.ubuntu.com/#http://tw.archive.ubuntu.com/#' /etc/apt/sources.list;
82-
83-
8477
RUN apt-get update \
8578
&& apt-get install -y --no-install-recommends curl ca-certificates gnupg patch
8679

@@ -94,14 +87,14 @@ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
9487
&& apt-get update \
9588
&& apt-get install -y yarn
9689

90+
ARG ABC
9791
ENV PREFIX_PATH "/app"
9892

93+
COPY image /
94+
9995
# build frontend
10096
COPY web /src/web
101-
RUN cd /src/web \
102-
&& yarn \
103-
&& npm run build
104-
97+
RUN /etc/install.sh
10598

10699
LABEL maintainer="Tobias Stein, fcwu.tw@gmail.com"
107100

@@ -110,11 +103,6 @@ RUN mkdir -p /usr/local/lib/web/frontend
110103

111104
RUN cp -R /src/web/dist/. /usr/local/lib/web/frontend/
112105

113-
COPY image /
114-
115-
# This has to be called in deriving images
116-
RUN python /etc/RenameURL.py
117-
118106
EXPOSE 80
119107
WORKDIR /root
120108
ENV HOME=/home/ubuntu \

Dockerfile.18.04

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Built with arch: amd64 flavor: lxde image: ubuntu:18.04 localbuild: 1
2+
#
3+
################################################################################
4+
# base system
5+
################################################################################
6+
7+
FROM ubuntu:18.04 as system
8+
9+
10+
11+
RUN sed -i 's#http://archive.ubuntu.com/#http://tw.archive.ubuntu.com/#' /etc/apt/sources.list;
12+
13+
14+
# built-in packages
15+
ENV DEBIAN_FRONTEND noninteractive
16+
RUN apt update \
17+
&& apt install -y --no-install-recommends software-properties-common curl apache2-utils \
18+
&& apt update \
19+
&& apt install -y --no-install-recommends --allow-unauthenticated \
20+
supervisor nginx sudo net-tools zenity xz-utils \
21+
dbus-x11 x11-utils alsa-utils \
22+
mesa-utils libgl1-mesa-dri \
23+
&& apt autoclean -y \
24+
&& apt autoremove -y \
25+
&& rm -rf /var/lib/apt/lists/*
26+
# install debs error if combine together
27+
RUN add-apt-repository -y ppa:fcwu-tw/apps \
28+
&& apt update \
29+
&& apt install -y --no-install-recommends --allow-unauthenticated \
30+
xvfb x11vnc=0.9.16-1 \
31+
vim-tiny firefox chromium-browser ttf-ubuntu-font-family ttf-wqy-zenhei \
32+
&& add-apt-repository -r ppa:fcwu-tw/apps \
33+
&& apt autoclean -y \
34+
&& apt autoremove -y \
35+
&& rm -rf /var/lib/apt/lists/*
36+
37+
RUN apt update \
38+
&& apt install -y --no-install-recommends --allow-unauthenticated \
39+
lxde gtk2-engines-murrine gnome-themes-standard gtk2-engines-pixbuf gtk2-engines-murrine arc-theme \
40+
&& apt autoclean -y \
41+
&& apt autoremove -y \
42+
&& rm -rf /var/lib/apt/lists/*
43+
44+
45+
# Additional packages require ~600MB
46+
# libreoffice pinta language-pack-zh-hant language-pack-gnome-zh-hant firefox-locale-zh-hant libreoffice-l10n-zh-tw
47+
48+
# tini for subreap
49+
ARG TINI_VERSION=v0.18.0
50+
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /bin/tini
51+
RUN chmod +x /bin/tini
52+
53+
# ffmpeg
54+
RUN apt update \
55+
&& apt install -y --no-install-recommends --allow-unauthenticated \
56+
ffmpeg \
57+
&& rm -rf /var/lib/apt/lists/* \
58+
&& mkdir /usr/local/ffmpeg \
59+
&& ln -s /usr/bin/ffmpeg /usr/local/ffmpeg/ffmpeg
60+
61+
# python library
62+
COPY image/usr/local/lib/web/backend/requirements.txt /tmp/
63+
RUN apt-get update \
64+
&& dpkg-query -W -f='${Package}\n' > /tmp/a.txt \
65+
&& apt-get install -y python-pip python-dev build-essential \
66+
&& pip install setuptools wheel && pip install -r /tmp/requirements.txt \
67+
&& dpkg-query -W -f='${Package}\n' > /tmp/b.txt \
68+
&& apt-get remove -y `diff --changed-group-format='%>' --unchanged-group-format='' /tmp/a.txt /tmp/b.txt | xargs` \
69+
&& apt-get autoclean -y \
70+
&& apt-get autoremove -y \
71+
&& rm -rf /var/lib/apt/lists/* \
72+
&& rm -rf /var/cache/apt/* /tmp/a.txt /tmp/b.txt
73+
74+
75+
################################################################################
76+
# builder
77+
################################################################################
78+
# FROM ubuntu:18.04 as builder
79+
80+
81+
RUN sed -i 's#http://archive.ubuntu.com/#http://tw.archive.ubuntu.com/#' /etc/apt/sources.list;
82+
83+
84+
RUN apt-get update \
85+
&& apt-get install -y --no-install-recommends curl ca-certificates gnupg patch
86+
87+
# nodejs
88+
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - \
89+
&& apt-get install -y nodejs
90+
91+
# yarn
92+
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
93+
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
94+
&& apt-get update \
95+
&& apt-get install -y yarn
96+
97+
ENV PREFIX_PATH "/app"
98+
99+
COPY image /
100+
101+
# build frontend
102+
COPY web /src/web
103+
RUN /etc/install.sh
104+
105+
LABEL maintainer="Tobias Stein, fcwu.tw@gmail.com"
106+
107+
# COPY --from=builder /src/web/dist/ /usr/local/lib/web/frontend/
108+
RUN mkdir -p /usr/local/lib/web/frontend
109+
110+
RUN cp -R /src/web/dist/. /usr/local/lib/web/frontend/
111+
112+
EXPOSE 80
113+
WORKDIR /root
114+
ENV HOME=/home/ubuntu \
115+
SHELL=/bin/bash
116+
HEALTHCHECK --interval=30s --timeout=5s CMD curl --fail http://127.0.0.1:6079/api/health
117+
ENTRYPOINT ["/startup.sh"]

image/etc/RenameURL.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import os, fnmatch
22

33
toFind = "/app"
4-
toReplace = os.getenv("PREFIX_PATH", "/app")
4+
toReplace = os.getenv("PREFIX_PATH")
5+
6+
if (toReplace is None):
7+
print("No path given by environment variable.")
8+
exit()
59

610
print("using path {0} ...".format(toReplace))
711

image/etc/install.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
echo 'Building Node.js project...'
3+
cd /src/web \
4+
&& yarn \
5+
&& npm run build
6+
7+
cp -R /src/web/dist/. /usr/local/lib/web/frontend/
8+
echo 'Build finished.'

image/startup.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,13 @@ chmod +x "/usr/local/lib/web/frontend$PREFIX_PATH/static/websockify/run"
6767
PASSWORD=
6868
HTTP_PASSWORD=
6969

70+
# dynamic prefix path renaming
71+
# if [ -n "$DYNAMIC_PREFIX_PATH" ]; then
72+
# PREFIX_PATH="$DYNAMIC_PREFIX_PATH"
73+
# echo "DYNAMIC_PREFIX_PATH: $PREFIX_PATH"
74+
# python /etc/RenameURL.py
75+
# /etc/install.sh
76+
# cat /etc/nginx/sites-enabled/default
77+
# fi
78+
7079
exec /bin/tini -- /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf

0 commit comments

Comments
 (0)