Commit c291f0f8 authored by Lennart Weller's avatar Lennart Weller

Removed secondary chart and instead use modified entrypoint

parent b53d2ed6
......@@ -9,7 +9,6 @@ env:
matrix:
- BASE=debian
- BASE=alpine
- BASE=chart
before_install:
- sudo apt-get -qq update
......
FROM node:8.15.1
# Build arguments to change source url, branch or tag
ARG CODIMD_REPOSITORY=https://github.com/codimd/server.git
ARG VERSION=master
# Set some default config variables
ENV DEBIAN_FRONTEND noninteractive
ENV DOCKERIZE_VERSION v0.6.1
ENV NODE_ENV=production
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \
tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \
rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
# Add configuraton and init files
COPY resources/config.json resources/.sequelizerc /files/
COPY resources/chart-entrypoint.sh /usr/local/bin/chart-entrypoint.sh
RUN apt-get update && \
apt-get install -y git build-essential jq && \
# Add fonts for PDF export
apt-get install -y fonts-noto && \
# Clone the source
git clone --depth 1 --branch "$VERSION" "$CODIMD_REPOSITORY" /codimd && \
# Print the cloned version and clean up git files
cd /codimd && \
git log --pretty=format:'%ad %h %d' --abbrev-commit --date=short -1 && echo && \
git rev-parse HEAD > /tmp/gitref && \
rm -rf /codimd/.git && \
# Mime the git repository for fullversion
mkdir /codimd/.git && \
mv /tmp/gitref /codimd/.git/HEAD && \
jq ".repository.url = \"${CODIMD_REPOSITORY}\"" /codimd/package.json > /codimd/package.new.json && \
mv /codimd/package.new.json /codimd/package.json && \
# Symlink configuration files
rm -f /codimd/config.json && ln -s /files/config.json /codimd/config.json && \
rm -f /codimd/.sequelizerc && ln -s /files/.sequelizerc /codimd/.sequelizerc && \
# Install NPM dependencies and build project
yarn install --pure-lockfile && \
yarn install --production=false --pure-lockfile && \
npm run build && \
# Clean up this layer
yarn install && \
yarn cache clean && \
apt-get remove -y --auto-remove build-essential git jq && \
apt-get clean && apt-get purge && rm -r /var/lib/apt/lists/* && \
# Create codimd user
adduser --uid 10000 --home /codimd/ --disabled-password --system codimd && \
chown -R codimd /codimd/
WORKDIR /codimd
EXPOSE 3000
USER codimd
ENTRYPOINT ["/usr/local/bin/chart-entrypoint.sh"]
CMD ["node", "app.js"]
#!/bin/sh
if [ "$HMD_DB_URL" != "" ] && [ "$CMD_DB_URL" = "" ]; then
CMD_DB_URL="$HMD_DB_URL"
fi
if [ "$HMD_IMAGE_UPLOAD_TYPE" != "" ] && [ "$CMD_IMAGE_UPLOAD_TYPE" = "" ]; then
CMD_IMAGE_UPLOAD_TYPE="$HMD_IMAGE_UPLOAD_TYPE"
fi
if [ "$CMD_DB_URL" = "" ]; then
CMD_DB_URL="postgres://hackmd:hackmdpass@hackmdPostgres:5432/hackmd"
fi
export CMD_DB_URL
DB_SOCKET=$(echo ${CMD_DB_URL} | sed -e 's/.*:\/\//\/\//' -e 's/.*\/\/[^@]*@//' -e 's/\/.*$//')
if [ "$DB_SOCKET" != "" ]; then
dockerize -wait tcp://${DB_SOCKET} -timeout 30s
fi
./node_modules/.bin/sequelize db:migrate
# Print warning if local data storage is used but no volume is mounted
[ "$CMD_IMAGE_UPLOAD_TYPE" = "filesystem" ] && { mountpoint -q ./public/uploads || {
echo "
#################################################################
### ###
### !!!WARNING!!! ###
### ###
### Using local uploads without persistence is ###
### dangerous. You'll loose your data on ###
### container removal. Check out: ###
### https://docs.docker.com/engine/tutorials/dockervolumes/ ###
### ###
### !!!WARNING!!! ###
### ###
#################################################################
";
} ; }
# run
exec "$@"
#!/bin/sh
# Use gosu if the container started with root privileges
[ $(id -u) -eq 0] && GOSU="gosu codimd" || GOSU=""
if [ "$HMD_DB_URL" != "" ] && [ "$CMD_DB_URL" = "" ]; then
CMD_DB_URL="$HMD_DB_URL"
fi
......@@ -20,7 +23,7 @@ if [ "$DB_SOCKET" != "" ]; then
dockerize -wait tcp://${DB_SOCKET} -timeout 30s
fi
gosu codimd node_modules/.bin/sequelize db:migrate
$GOSU ./node_modules/.bin/sequelize db:migrate
# Print warning if local data storage is used but no volume is mounted
[ "$CMD_IMAGE_UPLOAD_TYPE" = "filesystem" ] && { mountpoint -q ./public/uploads || {
......@@ -41,7 +44,7 @@ gosu codimd node_modules/.bin/sequelize db:migrate
} ; }
# Change owner and permission if filesystem backend is used
if [ "$CMD_IMAGE_UPLOAD_TYPE" = "filesystem" ]; then
if [ -z $GOSU && "$CMD_IMAGE_UPLOAD_TYPE" = "filesystem" ]; then
chown -R codimd ./public/uploads
chmod 700 ./public/uploads
fi
......@@ -50,4 +53,4 @@ fi
sleep 3
# run
exec gosu codimd "$@"
exec $GOSU "$@"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment