Skip to content

Commit d35021f

Browse files
committed
feat: add Dockerfiles for Node.js 18.5 buildpack and runtime with PostgreSQL client and font support
1 parent b1b0818 commit d35021f

2 files changed

Lines changed: 88 additions & 0 deletions

File tree

buildpack-18.5/Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
FROM node:18.5.0-bullseye
2+
3+
ENV DEBIAN_VERSION_NAME bullseye
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+
# upgrade npm to 6.10
19+
npm i -g npm@9.6.0 && \
20+
# install node-prune
21+
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 && \
27+
# setup github ssh key
28+
mkdir -p /home/hackmd/.ssh && \
29+
# ssh-keyscan -H github.com >> /home/hackmd/.ssh/known_hosts && \
30+
# setup git credential helper
31+
mkdir -p /home/hackmd/git && \
32+
git config --global credential.helper 'store --file /home/$USER_NAME/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
37+
38+
USER hackmd
39+
ENV PATH="/home/hackmd/.npm/bin:$PATH"
40+
WORKDIR /home/$USER_NAME/app
41+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
42+
CMD ["node"]

runtime-18.5/Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
FROM node:18.5.0-bullseye
2+
3+
ENV DEBIAN_VERSION_NAME=bullseye 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"]

0 commit comments

Comments
 (0)