Skip to content

Commit 5822466

Browse files
committed
feat: add node 16 runtime and buildpack
1 parent f5fd28b commit 5822466

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

buildpack-16/Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM node:16.20.2-bookworm
2+
3+
ENV DEBIAN_VERSION_NAME bookworm
4+
5+
ARG USER_NAME=hackmd
6+
ARG UID=1500
7+
ARG GID=1500
8+
9+
RUN set -xe && \
10+
apt-get update && \
11+
# install postgres client
12+
apt-get install -y --no-install-recommends apt-transport-https && \
13+
echo "deb http://apt.postgresql.org/pub/repos/apt/ ${DEBIAN_VERSION_NAME}-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
14+
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
15+
apt-get update && \
16+
apt-get install -y --no-install-recommends postgresql-client-11 && \
17+
rm -rf /var/lib/apt/lists/* && \
18+
# install node-prune
19+
npm i -g node-prune && npm cache clean --force && \
20+
# Add user and groupd
21+
groupadd --gid $GID $USER_NAME && \
22+
useradd --uid $UID --gid $USER_NAME --no-log-init --create-home $USER_NAME && \
23+
mkdir /home/$USER_NAME/.npm && \
24+
echo "prefix=/home/$USER_NAME/.npm/" > /home/$USER_NAME/.npmrc && \
25+
# setup github ssh key
26+
mkdir -p /home/hackmd/.ssh && \
27+
# ssh-keyscan -H github.com >> /home/hackmd/.ssh/known_hosts && \
28+
# setup git credential helper
29+
mkdir -p /home/hackmd/git && \
30+
git config --global credential.helper 'store --file /home/$USER_NAME/git/credentials' && \
31+
# setup app dir
32+
mkdir -p /home/$USER_NAME/app && \
33+
# adjust permission
34+
chown -R $USER_NAME:$USER_NAME /home/$USER_NAME
35+
36+
USER hackmd
37+
ENV PATH="/home/hackmd/.npm/bin:$PATH"
38+
WORKDIR /home/$USER_NAME/app
39+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
40+
CMD ["node"]

runtime-16/Dockerfile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM node:16.20.2-bookworm
2+
3+
ENV DEBIAN_VERSION_NAME=bookworm NODE_ENV=production
4+
ENV PORTCHECKER_VERSION=v1.1.0
5+
6+
ARG USER_NAME=hackmd
7+
ARG UID=1500
8+
ARG GID=1500
9+
10+
ADD common/fonts/*.otf /usr/share/fonts/opentype/noto/
11+
ADD common/fonts/*.ttf /usr/share/fonts/truetype/noto/
12+
# add font conf for fonts orders
13+
ADD common/local.conf /etc/fonts/
14+
15+
RUN set -xe && \
16+
apt-get update && \
17+
# install postgres client
18+
apt-get install -y --no-install-recommends apt-transport-https && \
19+
echo "deb http://apt.postgresql.org/pub/repos/apt/ ${DEBIAN_VERSION_NAME}-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
20+
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
21+
apt-get update && \
22+
apt-get install -y --no-install-recommends postgresql-client-11 && \
23+
rm -rf /var/lib/apt/lists/* && \
24+
# install pchecker
25+
wget https://github.com/hackmdio/portchecker/releases/download/${PORTCHECKER_VERSION}/portchecker-linux-$(dpkg --print-architecture).tar.gz && \
26+
tar xvf portchecker-linux-$(dpkg --print-architecture).tar.gz -C /usr/local/bin && \
27+
mv /usr/local/bin/portchecker-linux-$(dpkg --print-architecture) /usr/local/bin/pcheck && \
28+
rm portchecker-linux-$(dpkg --print-architecture).tar.gz && \
29+
# Add user and groupd
30+
groupadd --gid $GID $USER_NAME && \
31+
useradd --uid $UID --gid $USER_NAME --no-log-init --create-home $USER_NAME && \
32+
mkdir /home/$USER_NAME/.npm && \
33+
echo "prefix=/home/$USER_NAME/.npm/" > /home/$USER_NAME/.npmrc && \
34+
# setup app dir
35+
mkdir -p /home/$USER_NAME/app && \
36+
# adjust permission
37+
chown -R $USER_NAME:$USER_NAME /home/$USER_NAME && \
38+
fc-cache -f -v && \
39+
dpkg-reconfigure fontconfig-config && \
40+
dpkg-reconfigure fontconfig
41+
42+
USER hackmd
43+
ENV PATH="/home/hackmd/.npm/bin:$PATH"
44+
WORKDIR /home/$USER_NAME/app
45+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
46+
CMD ["node"]
47+

0 commit comments

Comments
 (0)