Commit 4fc9ff57 authored by Lennart Weller's avatar Lennart Weller

Added UID parameter and some additional changes

  - Added UID argument to the dockerfile
  - Added warning in case fs permissions can't be automatically set
parent c291f0f8
......@@ -3,6 +3,7 @@ FROM node:8.15.1-alpine
# Build arguments to change source url, branch or tag
ARG CODIMD_REPOSITORY=https://github.com/codimd/server.git
ARG VERSION=master
ARG UID=10000
# Set some default config variables
ENV DOCKERIZE_VERSION=v0.6.1
......@@ -76,7 +77,7 @@ RUN apk add --no-cache --virtual .dep build-base openssl-dev python git jq bash
yarn install && \
yarn cache clean && \
apk del .dep && \
adduser -u 10000 -h /codimd/ -D -S codimd && \
adduser -u $UID -h /codimd/ -D -S codimd && \
chown -R codimd /codimd/
WORKDIR /codimd
......
......@@ -3,6 +3,7 @@ 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
ARG UID=10000
# Set some default config variables
ENV DEBIAN_FRONTEND noninteractive
......@@ -67,7 +68,7 @@ RUN apt-get update && \
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 && \
adduser --uid $UID --home /codimd/ --disabled-password --system codimd && \
chown -R codimd /codimd/
WORKDIR /codimd
......
#!/bin/sh
# Use gosu if the container started with root privileges
[ $(id -u) -eq 0] && GOSU="gosu codimd" || GOSU=""
UID=$(id -u)
[ $UID -eq 0] && GOSU="gosu codimd" || GOSU=""
if [ "$HMD_DB_URL" != "" ] && [ "$CMD_DB_URL" = "" ]; then
CMD_DB_URL="$HMD_DB_URL"
......@@ -43,10 +44,27 @@ $GOSU ./node_modules/.bin/sequelize db:migrate
";
} ; }
# Change owner and permission if filesystem backend is used
if [ -z $GOSU && "$CMD_IMAGE_UPLOAD_TYPE" = "filesystem" ]; then
chown -R codimd ./public/uploads
chmod 700 ./public/uploads
# Change owner and permission if filesystem backend is used and user has root permissions
if [ $UID -eq 0 && "$CMD_IMAGE_UPLOAD_TYPE" = "filesystem" ]; then
if [ $UID -eq 0 ]; then
chown -R codimd ./public/uploads
chmod 700 ./public/uploads
else
echo "
#################################################################
### ###
### !!!WARNING!!! ###
### ###
### Container was started without root permissions ###
### and filesystem storage is being used. ###
### In case of filesystem errors these need to be ###
### changed manually ###
### ###
### !!!WARNING!!! ###
### ###
#################################################################
";
fi
fi
# Sleep to make sure everything is fine...
......
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