david/jekyll-dev
david
/
jekyll-dev
Archived
1
0
Fork 0

added user and group id mapping

This commit is contained in:
david 2020-10-28 19:18:30 +01:00
parent 99def1dad5
commit 55b15f7fbd
3 changed files with 16 additions and 19 deletions

View File

@ -7,10 +7,8 @@ LABEL Description="This image is used to learn building dockerfiles" \
# environment variables
ENV JEKYLL_SITE=default
# copy stuff into the image
COPY jekyll.sh jekyll.sh
RUN chmod +x jekyll.sh
ENV USER_ID=1000
ENV GROUP_ID=1000
# expose port for `jekyll serve`
EXPOSE 4000
@ -18,9 +16,17 @@ EXPOSE 4000
# volume definitions
VOLUME ["/mnt"]
# prepare the baseimage
# prepare the baseimage and create
RUN apt-get update && apt-get install -y ruby ruby-dev gcc g++ make libssl-dev libreadline-dev && \
gem update && gem install jekyll bundler
gem update && gem install jekyll bundler && \
groupadd -g $GROUP_ID jekyll-dev && \
useradd -u $USER_ID -g $GROUP_ID -M -d /mnt -s /bin/false jekyll-dev
USER jekyll-dev
RUN cd /mnt && \
if [ ! -d "/mnt/$JEKYLL_SITE" ]; then jekyll new $JEKYLL_SITE; fi && \
cd $JEKYLL_SITE && bundle install
# run command
CMD ./jekyll.sh
CMD bundle exec jekyll serve --host=0.0.0.0 --incremental

View File

@ -10,4 +10,6 @@ services:
ports:
- 127.0.0.1:4000:4000
environment:
- JEKYLL_SITE=docs
- JEKYLL_SITE=docs
- USER_ID=1000
- GROUP_ID=1000

View File

@ -1,11 +0,0 @@
#!/bin/bash
# create new or serve existing jekyll page (/mnt/$JEKYLL_SITE)
cd /mnt
if [ ! -d "/mnt/$JEKYLL_SITE" ]; then
jekyll new $JEKYLL_SITE
fi
cd $JEKYLL_SITE
bundle install
bundle exec jekyll serve --host=0.0.0.0 --incremental