Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2017-05-30 00:21:44 +02:00
commit b0a89cd406
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
4 changed files with 167 additions and 0 deletions

71
Dockerfile Normal file
View file

@ -0,0 +1,71 @@
FROM node:7
ENV VERSION master
# ENV DEBUG true
# ENV HMD_DOMAIN localhost
# ENV HMD_URL_PATH ""
# ENV HMD_PORT 3000
# ENV HMD_ALLOW_ORIGIN localhost, hackmd.io
# ENV HMD_PROTOCOL_USESSL true
# ENV HMD_URL_ADDPORT true
# ENV HMD_USECDN true
# ENV HMD_ALLOW_ANONYMOUS true
# ENV HMD_ALLOW_FREEURL true
# ENV HMD_DEFAULT_PERMISSION locked
# ENV HMD_DB_URL sqlite:///data/db.sqlite
# ENV HMD_FACEBOOK_CLIENTID ""
# ENV HMD_FACEBOOK_CLIENTSECRET ""
# ENV HMD_TWITTER_CONSUMERKEY ""
# ENV HMD_TWITTER_CONSUMERSECRET ""
# ENV HMD_GITHUB_CLIENTID ""
# ENV HMD_GITHUB_CLIENTSECRET ""
# ENV HMD_GITLAB_SCOPE api
# ENV HMD_GITLAB_BASEURL ""
# ENV HMD_GITLAB_CLIENTID ""
# ENV HMD_GITLAB_CLIENTSECRET ""
# ENV HMD_DROPBOX_CLIENTID ""
# ENV HMD_DROPBOX_CLIENTSECRET ""
# ENV HMD_GOOGLE_CLIENTID ""
# ENV HMD_GOOGLE_CLIENTSECRET ""
# ENV HMD_LDAP_URL ""
# ENV HMD_LDAP_BINDDN ""
# ENV HMD_LDAP_BINDCREDENTIALS ""
# ENV HMD_LDAP_TOKENSECRET ""
# ENV HMD_LDAP_SEARCHBASE ""
# ENV HMD_LDAP_SEARCHFILTER ""
# ENV HMD_LDAP_SEARCHATTRIBUTES ""
# ENV HMD_LDAP_TLS_CA ""
# ENV HMD_LDAP_PROVIDERNAME ""
# ENV HMD_IMGUR_CLIENTID ""
# ENV HMD_EMAIL true
# ENV HMD_ALLOW_EMAIL_REGISTER true
# ENV HMD_IMAGE_UPLOAD_TYPE filesystem
# ENV HMD_S3_ACCESS_KEY_ID ""
# ENV HMD_S3_SECRET_ACCESS_KEY ""
# ENV HMD_S3_REGION ""
# 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
WORKDIR /hackmd
RUN set -ex \
&& npm install \
&& npm install webpack \
&& npm run build
ADD run.sh /usr/local/bin/run.sh
ADD config.json /hackmd/config.json.default
ADD sequelizerc /hackmd/.sequelizerc.default
EXPOSE 3000
VOLUME /config
VOLUME /data
VOLUME /hackmd/public/uploads
ENV NODE_ENV production
CMD ["/usr/local/bin/run.sh"]

64
config.json Normal file
View file

@ -0,0 +1,64 @@
{
"test": {
"db": {
"dialect": "sqlite",
"storage": ":memory:"
}
},
"development": {
"db": {
"dialect": "sqlite",
"storage": "./db.hackmd.sqlite"
}
},
"production": {
"domain": "localhost",
"db": {
"dialect": "sqlite",
"storage": "/data/db.sqlite"
},
"facebook": {
"clientID": "change this",
"clientSecret": "change this"
},
"twitter": {
"consumerKey": "change this",
"consumerSecret": "change this"
},
"github": {
"clientID": "change this",
"clientSecret": "change this"
},
"gitlab": {
"baseURL": "change this",
"clientID": "change this",
"clientSecret": "change this",
"scope": "use 'read_user' scope for auth user only or remove this property if you need gitlab snippet import/export support (will result to be default scope 'api')"
},
"dropbox": {
"clientID": "change this",
"clientSecret": "change this",
"appKey": "change this"
},
"google": {
"clientID": "change this",
"clientSecret": "change this",
"apiKey": "change this"
},
"ldap": {
"url": "ldap://change_this",
"bindDn": null,
"bindCredentials": null,
"tokenSecret": "change this",
"searchBase": "change this",
"searchFilter": "change this",
"searchAttributes": "change this",
"tlsOptions": {
"changeme": "See https://nodejs.org/api/tls.html#tls_tls_connect_options_callback"
}
},
"imgur": {
"clientID": "change this"
}
}
}

24
run.sh Executable file
View file

@ -0,0 +1,24 @@
#!/bin/bash
set -o pipefail
set -ex
if ! [ -f /config/config.json ]; then
cp config.json.default config.json
else
cp /config/config.json config.json
fi
if ! [ -f /config/.sequelizerc ]; then
cp .sequelizerc.default .sequelizerc
else
cp /config/.sequelizerc .sequelizerc
fi
if [ -f /config/client_config.js ]; then
cp /config/client_config.js public/js/config.js
fi
node_modules/.bin/sequelize db:migrate
exec npm run start

8
sequelizerc Normal file
View file

@ -0,0 +1,8 @@
var path = require('path');
module.exports = {
'config': path.resolve('config.json'),
'migrations-path': path.resolve('lib', 'migrations'),
'models-path': path.resolve('lib', 'models'),
'url': 'sqlite:///data/db.sqlite'
}