diff --git a/Dockerfile b/Dockerfile index dc2ef05..980de0e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,33 @@ -FROM node:7 +FROM node:7-alpine as builder -ENV VERSION master +ARG CODIMD_VERSION=1.2.1 +ARG BUILD_ASSETS=false + +RUN set -ex \ + && apk add --no-cache \ + bash \ + build-base \ + curl \ + git \ + make \ + python \ + tar \ + && mkdir /hackmd \ + && curl -sSfL https://github.com/hackmdio/codimd/archive/${CODIMD_VERSION}.tar.gz | tar -xzf - --strip-components=1 -C /hackmd \ + && cd /hackmd \ + && npm install --loglevel warn \ + grunt \ + webpack \ + webpack-cli \ + && npm install --loglevel warn \ + && npm run build \ + && rm -rf node_modules \ + && NODE_ENV=production npm install --loglevel warn + + +FROM node:7-alpine + +LABEL codimd_version=1.2.1 # ENV DEBUG true # ENV HMD_DOMAIN localhost @@ -47,17 +74,11 @@ ENV VERSION master # ENV HMD_S3_BUCKET "" RUN set -ex \ - && mkdir /hackmd \ - && curl -sSfL https://github.com/hackmdio/hackmd/archive/${VERSION}.tar.gz | tar -xzf - --strip-components=1 -C /hackmd + && apk add --no-cache bash -WORKDIR /hackmd +COPY --from=builder /hackmd /hackmd -RUN set -ex \ - && npm install webpack \ - && npm install \ - && npm run build - -ADD run.sh /usr/local/bin/run.sh +ADD run.sh /usr/local/bin/run.sh ADD config.json /hackmd/config.json.default ADD sequelizerc /hackmd/.sequelizerc.default diff --git a/run.sh b/run.sh index 02dc2a7..c4b91d4 100755 --- a/run.sh +++ b/run.sh @@ -1,22 +1,22 @@ #!/bin/bash +set -euxo pipefail -set -o pipefail -set -ex +cd /hackmd if ! [ -f /config/config.json ]; then - cp config.json.default config.json + cp config.json.default config.json else - cp /config/config.json config.json + cp /config/config.json config.json fi if ! [ -f /config/.sequelizerc ]; then - cp .sequelizerc.default .sequelizerc + cp .sequelizerc.default .sequelizerc else - cp /config/.sequelizerc .sequelizerc + cp /config/.sequelizerc .sequelizerc fi if [ -f /config/client_config.js ]; then - cp /config/client_config.js public/js/config.js + cp /config/client_config.js public/js/config.js fi node_modules/.bin/sequelize db:migrate