forked from hackmdio/docker-hackmd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
82 lines (72 loc) · 2.88 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
FROM node:8.11.4-alpine
# Build arguments to change source url, branch or tag
ARG HACKMD_REPOSITORY=https://github.com/jaswanth098/codimd.git
ARG VERSION=google-allowed-domains
# Set some default config variables
ENV DOCKERIZE_VERSION=v0.6.1
ENV NODE_ENV=production
# Disable PDF export on alpine
# PhantomJS is broken on alpine and crashes HackMD
ENV HMD_ALLOW_PDF_EXPORT=false
RUN apk add --no-cache --virtual .download wget ca-certificates && \
wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \
tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \
rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \
apk del .download
ENV GOSU_VERSION 1.10
COPY resources/gosu-gpg.key /tmp/gosu.key
RUN set -ex; \
\
apk add --no-cache --virtual .gosu-deps \
wget \
ca-certificates \
dpkg \
gnupg \
openssl \
; \
\
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
\
# verify the signature
export GNUPGHOME="$(mktemp -d)"; \
gpg --import /tmp/gosu.key; \
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
\
chmod +x /usr/local/bin/gosu; \
# verify that the binary works
gosu nobody true; \
\
apk del .gosu-deps
# Add configuraton files
COPY resources/config.json resources/.sequelizerc /files/
# Install all dependencies and build project
RUN apk add --no-cache --virtual .dep build-base python git bash && \
# Clone the source
git clone --depth 1 --branch $VERSION $HACKMD_REPOSITORY /hackmd && \
# Print the cloned version and clean up git files
cd /hackmd && \
git log --pretty=format:'%ad %h %d' --abbrev-commit --date=short -1 && echo && \
rm -rf /hackmd/.git && \
# Symlink configuration files
rm -f /hackmd/config.json && ln -s /files/config.json /hackmd/config.json && \
rm -f /hackmd/.sequelizerc && ln -s /files/.sequelizerc /hackmd/.sequelizerc && \
# Install NPM dependencies and build project
yarn install --pure-lockfile && \
yarn install --production=false --pure-lockfile && \
yarn global add webpack && \
npm run build && \
# Clean up this layer
yarn install && \
yarn cache clean && \
apk del .dep && \
adduser -u 10000 -h /hackmd/ -D -S hackmd && \
chown -R hackmd /hackmd/
WORKDIR /hackmd
EXPOSE 3000
# Add entrypoint and set command
COPY resources/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["node", "app.js"]