Skip to content

Commit 1c3f34a

Browse files
author
Tobias Stein
committed
Add docker file with reusable node build
1 parent c850262 commit 1c3f34a

File tree

1 file changed

+118
-1
lines changed

1 file changed

+118
-1
lines changed

Dockerfile

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,118 @@
1-
Dockerfile.amd64
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+
# build frontend
98+
COPY web /src/web
99+
RUN cd /src/web \
100+
&& yarn \
101+
&& npm run build
102+
103+
104+
LABEL maintainer="Tobias Stein, fcwu.tw@gmail.com"
105+
106+
# COPY --from=builder /src/web/dist/ /usr/local/lib/web/frontend/
107+
RUN mkdir -p /usr/local/lib/web/frontend
108+
109+
RUN cp -R /src/web/dist/. /usr/local/lib/web/frontend/
110+
111+
COPY image /
112+
113+
EXPOSE 80
114+
WORKDIR /root
115+
ENV HOME=/home/ubuntu \
116+
SHELL=/bin/bash
117+
HEALTHCHECK --interval=30s --timeout=5s CMD curl --fail http://127.0.0.1:6079/api/health
118+
ENTRYPOINT ["/startup.sh"]

0 commit comments

Comments
 (0)