Skip to content

Commit a1f13d5

Browse files
committed
feat: 1.0.3
1. runtime add sequelize package 2. buildpack add hackmd user
1 parent b3fa789 commit a1f13d5

File tree

2 files changed

+36
-21
lines changed

2 files changed

+36
-21
lines changed

buildpack/Dockerfile

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ FROM node:8.16.0-jessie
22

33
ENV DEBIAN_VERSION_NAME jessie
44

5-
RUN set -x && \
5+
ARG USER_NAME=hackmd
6+
ARG UID=1500
7+
ARG GID=1500
8+
9+
RUN set -xe && \
610
apt-get update && \
711
# install postgres client
812
apt-get install -y --no-install-recommends apt-transport-https && \
@@ -15,13 +19,24 @@ RUN set -x && \
1519
npm i -g npm@6.10.3 && \
1620
# install node-prune
1721
npm i -g node-prune && npm cache clean --force && \
22+
# Add user and groupd
23+
groupadd --gid $GID $USER_NAME && \
24+
useradd --uid $UID --gid $USER_NAME --no-log-init --create-home $USER_NAME && \
25+
mkdir /home/$USER_NAME/.npm && \
26+
echo "prefix=/home/$USER_NAME/.npm/" > /home/$USER_NAME/.npmrc && \
1827
# setup github ssh key
19-
mkdir -p /root/.ssh && \
20-
ssh-keyscan -H github.com >> /root/.ssh/known_hosts && \
28+
mkdir -p /home/hackmd/.ssh && \
29+
ssh-keyscan -H github.com >> /home/hackmd/.ssh/known_hosts && \
2130
# setup git credential helper
22-
mkdir -p /root/git && \
23-
git config --global credential.helper 'store --file /root/git/credentials'
31+
mkdir -p /home/hackmd/git && \
32+
git config --global credential.helper 'store --file /home/hackmd/git/credentials' && \
33+
# setup app dir
34+
mkdir -p /home/$USER_NAME/app && \
35+
# adjust permission
36+
chown -R $USER_NAME:$USER_NAME /home/$USER_NAME
2437

38+
USER hackmd
39+
ENV PATH="/home/hackmd/.npm/bin:$PATH"
40+
WORKDIR /home/$USER_NAME/app
2541
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
26-
2742
CMD ["node"]

runtime/Dockerfile

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
FROM node:8.16.0-jessie
22

3-
ENV DEBIAN_VERSION_NAME jessie
3+
ENV DEBIAN_VERSION_NAME=jessie NODE_ENV=production
44
ENV NODE_ENV production
55

66
ARG USER_NAME=hackmd
77
ARG UID=1500
88
ARG GID=1500
99

10+
ADD fonts/*.otf /usr/share/fonts/opentype/noto/
11+
ADD fonts/*.ttf /usr/share/fonts/truetype/noto/
12+
# add font conf for fonts orders
13+
ADD local.conf /etc/fonts/
14+
1015
RUN set -xe && \
1116
apt-get update && \
1217
# install postgres client
@@ -20,31 +25,26 @@ RUN set -xe && \
2025
wget https://github.com/hackmdio/portchecker/releases/download/v1.0.2/portchecker-linux-amd64.tar.gz && \
2126
tar xvf portchecker-linux-amd64.tar.gz -C /usr/local/bin && \
2227
mv /usr/local/bin/portchecker-linux-amd64 /usr/local/bin/pcheck && \
28+
rm portchecker-linux-amd64.tar.gz && \
2329
# Add user and groupd
2430
groupadd --gid $GID $USER_NAME && \
2531
useradd --uid $UID --gid $USER_NAME --no-log-init --create-home $USER_NAME && \
26-
mkdir /home/$USER_NAME/.npm-global && \
27-
echo "prefix=/home/$USER_NAME/.npm-global/" > /home/$USER_NAME/.npmrc && \
32+
mkdir /home/$USER_NAME/.npm && \
33+
echo "prefix=/home/$USER_NAME/.npm/" > /home/$USER_NAME/.npmrc && \
2834
# setup app dir
2935
mkdir -p /home/$USER_NAME/app && \
3036
# adjust permission
31-
chown -R $USER_NAME:$USER_NAME /home/$USER_NAME
32-
33-
ADD fonts/*.otf /usr/share/fonts/opentype/noto/
34-
ADD fonts/*.ttf /usr/share/fonts/truetype/noto/
35-
# add font conf for fonts orders
36-
ADD local.conf /etc/fonts/
37-
38-
RUN fc-cache -f -v && \
37+
chown -R $USER_NAME:$USER_NAME /home/$USER_NAME && \
38+
su - hackmd -c "npm install -g sequelize-cli@4.1.1 sequelize@4.13.11 npm@6.10.3 && npm cache clean --force" && \
39+
fc-cache -f -v && \
3940
dpkg-reconfigure fontconfig-config && \
4041
dpkg-reconfigure fontconfig
4142

42-
USER hackmd
43-
RUN npm install -g sequelize-cli npm@6.10.3
43+
#RUN npm install -g sequelize-cli@4.1.1 sequelize@4.13.11 npm@6.10.3
4444

45+
USER hackmd
46+
ENV PATH="/home/hackmd/.npm/bin:$PATH"
4547
WORKDIR /home/$USER_NAME/app
46-
4748
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
48-
4949
CMD ["node"]
5050

0 commit comments

Comments
 (0)