diff --git a/Dockerfile.amd64 b/Dockerfile.amd64 index 5035eec..3b8f580 100644 --- a/Dockerfile.amd64 +++ b/Dockerfile.amd64 @@ -48,34 +48,6 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* \ && rm -rf /var/cache/apt/* /tmp/a.txt /tmp/b.txt - -################################################################################ -# builder -################################################################################ -FROM ubuntu:16.04 as builder - -ARG localbuild -RUN if [ "x$localbuild" != "x" ]; then sed -i 's#http://archive.ubuntu.com/#http://tw.archive.ubuntu.com/#' /etc/apt/sources.list; fi - -RUN apt-get update \ - && apt-get install -y --no-install-recommends curl ca-certificates - -# nodejs -RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - \ - && apt-get install -y nodejs - -# yarn -RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ - && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ - && apt-get update \ - && apt-get install -y yarn - -# build frontend -COPY web /src/web -RUN cd /src/web \ - && yarn \ - && npm run build - # start installing Yocto base host packages, git, tar, python RUN apt-get update && apt-get install -y --no-install-recommends git tar python3 @@ -104,15 +76,33 @@ RUN apt-get update && apt-get install -y --no-install-recommends emacs RUN apt-get update -# now install ~/bin directory with repo from NXP i.MX recommended yocto packages -RUN mkdir ~/bin -RUN curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo -RUN sudo chmod a+x ~/bin/repo -# now clone Poky in (from Yocto quick setup guide) -RUN apt-get update -RUN git clone git://git.yoctoproject.org/poky -RUN git checkout tags/yocto-2.5 -b my-yocto-2.5 +################################################################################ +# builder +################################################################################ +FROM ubuntu:16.04 as builder + +ARG localbuild +RUN if [ "x$localbuild" != "x" ]; then sed -i 's#http://archive.ubuntu.com/#http://tw.archive.ubuntu.com/#' /etc/apt/sources.list; fi + +RUN apt-get update \ + && apt-get install -y --no-install-recommends curl ca-certificates + +# nodejs +RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - \ + && apt-get install -y nodejs + +# yarn +RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ + && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ + && apt-get update \ + && apt-get install -y yarn + +# build frontend +COPY web /src/web +RUN cd /src/web \ + && yarn \ + && npm run build ################################################################################ # merge @@ -123,6 +113,20 @@ LABEL maintainer="fcwu.tw@gmail.com" COPY --from=builder /src/web/dist/ /usr/local/lib/web/frontend/ COPY image / +# now install ~/bin directory with repo from NXP i.MX recommended yocto packages +#RUN mkdir ~/bin && curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo && chmod a+x ~/bin/repo + +# now clone Poky in (from Yocto quick setup guide) +#RUN apt-get update && mkdir -p /root/poky && echo $PWD && git clone git://git.yoctoproject.org/poky /root/poky && echo $PWD && cd /root/poky && echo $PWD && git checkout tags/yocto-2.5 -b my-yocto-2.5 +#RUN cd /root +#RUN pwd +#RUN git clone git://git.yoctoproject.org/poky +#RUN pwd +#RUN cd ./poky +#RUN pwd +#RUN ls +#RUN git checkout tags/yocto-2.5 -b my-yocto-2.5 + EXPOSE 80 WORKDIR /home ENV HOME=/home/ \ diff --git a/image/startup.sh b/image/startup.sh index 80bcae3..04586b1 100755 --- a/image/startup.sh +++ b/image/startup.sh @@ -1,6 +1,8 @@ #!/bin/bash +echo "Beginning of startup.sh script" if [ -n "$VNC_PASSWORD" ]; then + echo "starting set password section" echo -n "$VNC_PASSWORD" > /.password1 x11vnc -storepasswd $(cat /.password1) /.password2 chmod 400 /.password* @@ -9,12 +11,16 @@ if [ -n "$VNC_PASSWORD" ]; then fi if [ -n "$RESOLUTION" ]; then + echo "starting set resolution section" sed -i "s/1024x768/$RESOLUTION/" /usr/local/bin/xvfb.sh fi +echo "setting USER to root" USER=${USER:-root} +echo "setting HOME to root" HOME=/root if [ "$USER" != "root" ]; then + echo "starting user not equal to root" echo "* enable custom user: $USER" useradd --create-home --shell /bin/bash --user-group --groups adm,sudo $USER if [ -z "$PASSWORD" ]; then @@ -26,37 +32,93 @@ if [ "$USER" != "root" ]; then cp -r /root/{.gtkrc-2.0,.asoundrc} ${HOME} [ -d "/dev/snd" ] && chgrp -R adm /dev/snd fi + +echo "starting sed -i etc, supervisor, conf.d, supervisord.conf" sed -i "s|%USER%|$USER|" /etc/supervisor/conf.d/supervisord.conf + +echo "starting 2nd line of sed -i etc, supervisor, conf.d, supervisord.conf" sed -i "s|%HOME%|$HOME|" /etc/supervisor/conf.d/supervisord.conf # home folder +echo "about to mkdir for .config, pacmanfm, lxde" mkdir -p $HOME/.config/pcmanfm/LXDE/ +echo "about to ln -sf /usr/local/share/doro-lxde-wallpapers/desktop-teims.blah" + ln -sf /usr/local/share/doro-lxde-wallpapers/desktop-items-0.conf $HOME/.config/pcmanfm/LXDE/ -chown -R $USER:$USER $HOME +echo "about to chown USER" + +chown -R --verbose $USER:$USER $HOME # nginx workers +echo "about to sed -i nginx workers" sed -i 's|worker_processes .*|worker_processes 1;|' /etc/nginx/nginx.conf # nginx ssl if [ -n "$SSL_PORT" ] && [ -e "/etc/nginx/ssl/nginx.key" ]; then echo "* enable SSL" + echo "starting to enable SSL" sed -i 's|#_SSL_PORT_#\(.*\)443\(.*\)|\1'$SSL_PORT'\2|' /etc/nginx/sites-enabled/default sed -i 's|#_SSL_PORT_#||' /etc/nginx/sites-enabled/default fi # nginx http base authentication if [ -n "$HTTP_PASSWORD" ]; then + echo "about to enable http base authentication" echo "* enable HTTP base authentication" htpasswd -bc /etc/nginx/.htpasswd $USER $HTTP_PASSWORD sed -i 's|#_HTTP_PASSWORD_#||' /etc/nginx/sites-enabled/default fi # novnc websockify +echo "about to novnc websockify" +echo "about to ln -s /usr/local/lib/web/frontend/static/websockify" + ln -s /usr/local/lib/web/frontend/static/websockify /usr/local/lib/web/frontend/static/novnc/utils/websockify +echo "about to chmod +x /usr/local/lib/web/frontend/static/websockify/run" chmod +x /usr/local/lib/web/frontend/static/websockify/run # clearup +echo "clearup. about to set password and http_password to null" + PASSWORD= HTTP_PASSWORD= + +BINDIRECTORY="~/bin" +REPODIRECTORY="~/bin/repo" +if [ ! -d "$BINDIRECTORY" ]; then + + # Control will enter here if ~/bin doesn't exist. + # now mkdir ~/bin and install ~/bin/repo directory with repo from NXP i.MX recommended yocto packages + mkdir ~/bin + curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo + chmod a+x ~/bin/repo +elif [ ! -d "REPODIRECTORY" ]; then + # Control will enter here if ~/bin DOES exist but ~/bin/repo doesn't exist. + # now install ~/bin directory with repo from NXP i.MX recommended yocto packages + curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo + chmod a+x ~/bin/repo +else + echo "something went wrong with curl of i.MX recommended packages" +fi + +# now clone Poky in (from Yocto quick setup guide) +apt-get update + +POKYDIR="/root/poky" +if [ ! -d "$POKYDIR" ]; then + + mkdir -p $POKYDIR + echo $PWD + git clone git://git.yoctoproject.org/poky $POKYDIR + echo $PWD + cd $POKYDIR + echo $PWD + git checkout tags/yocto-2.5 -b my-yocto-2.5 +fi + + + +echo "about to exec /bin/tini -- usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf" + exec /bin/tini -- /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf