diff --git a/.gitignore b/.gitignore index d9f93b9c..acefd488 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ dist/ /npm-debug.log* /package-lock.json /yarn-error.log -/lerna-debug.log \ No newline at end of file +/lerna-debug.log +/Dockerfile-dev diff --git a/Dockerfile b/Dockerfile index b3d0474c..4a6ca840 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,28 @@ +FROM node:alpine as builder + +RUN apk add --no-cache make gcc g++ python git +RUN git clone https://github.com/droppy-js/droppy /droppy +RUN rm -rf /droppy/node_modules && \ + cd /droppy && \ + yarn && \ + yarn bootstrap + FROM node:alpine LABEL maintainer="https://github.com/droppy-js/droppy" # Copy files -COPY ["node_modules", "/droppy/node_modules"] -COPY ["packages/client", "/droppy/client"] -COPY ["packages/server", "/droppy/server"] -COPY ["packages/cli", "/droppy/cli"] -COPY ["dist", "/droppy/dist"] -COPY ["droppy.js", "docker-start.sh", "README.md", "LICENSE", "package.json", "/droppy/"] +COPY --from=builder ["/droppy/node_modules", "/droppy/node_modules"] +COPY --from=builder ["/droppy/packages/client", "/droppy/client"] +COPY --from=builder ["/droppy/packages/server", "/droppy/server"] +COPY --from=builder ["/droppy/packages/cli", "/droppy/cli"] +COPY --from=builder ["/droppy/docker-start.sh", "/droppy/README.md", "/droppy/LICENSE", "/droppy/"] # Install build dependencies and and build modules RUN cd /droppy && \ - find /droppy -type d -exec chmod 0755 {} + && \ - find /droppy -type f -exec chmod 0644 {} + && \ chmod 0755 /droppy/docker-start.sh && \ - chmod 0755 /droppy/droppy.js && \ mkdir -p /root/.droppy && \ ln -s /config /root/.droppy/config && \ ln -s /files /root/.droppy/files && \ - ln -s /droppy/droppy.js /usr/bin/droppy && \ rm -rf \ /root/.config \ /root/.node-gyp \ diff --git a/Makefile b/Makefile index 23c9888b..9013b9b9 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,12 @@ jquery: cat /tmp/jquery/dist/jquery.min.js | perl -pe 's|"3\..+?"|"3"|' > $(CURDIR)/client/jquery-custom.min.js rm -rf /tmp/jquery +Dockerfile-dev: Dockerfile + cat Dockerfile | sed -e 's/^RUN git clone.*/COPY [ ".", "\/droppy" ]/' > Dockerfile-dev + +docker-dev: Dockerfile-dev + docker build -t localhost/local/droppy-dev -f Dockerfile-dev . + patch: test build ver-patch docker publish minor: test build ver-minor docker publish major: test build ver-major docker publish diff --git a/docker-start.sh b/docker-start.sh index 2901fc31..60b2838b 100755 --- a/docker-start.sh +++ b/docker-start.sh @@ -5,7 +5,7 @@ # echo >> /etc/xxx and not adduser/addgroup because adduser/addgroup # won't work if uid/gid already exists. -echo -e "droppy:x:${UID}:${GID}:droppy:/droppy:/bin/false\n" >> /etc/passwd +echo -e "droppy:x:${UID}:${GID}:droppy:/home/droppy:/bin/false\n" >> /etc/passwd echo -e "droppy:x:${GID}:droppy\n" >> /etc/group # it's better to do that (mkdir and chown) here than in the Dockerfile @@ -13,7 +13,16 @@ echo -e "droppy:x:${GID}:droppy\n" >> /etc/group mkdir -p /config mkdir -p /files +mkdir -p /home/droppy/.droppy + +ln -s /config /home/droppy/.droppy/config +ln -s /files /home/droppy/.droppy/files + +chown -R droppy:droppy /home/droppy + chown -R droppy:droppy /config chown droppy:droppy /files -exec /bin/su -p -s "/bin/sh" -c "exec /usr/bin/droppy start --color -f /files -c /config" droppy +export HOME=/home/droppy + +exec /bin/su -l -p -s "/bin/sh" -c "exec node /droppy/cli/lib/cli.js start" droppy