added user and group id mapping
This commit is contained in:
parent
99def1dad5
commit
55b15f7fbd
20
Dockerfile
20
Dockerfile
|
@ -7,10 +7,8 @@ LABEL Description="This image is used to learn building dockerfiles" \
|
||||||
|
|
||||||
# environment variables
|
# environment variables
|
||||||
ENV JEKYLL_SITE=default
|
ENV JEKYLL_SITE=default
|
||||||
|
ENV USER_ID=1000
|
||||||
# copy stuff into the image
|
ENV GROUP_ID=1000
|
||||||
COPY jekyll.sh jekyll.sh
|
|
||||||
RUN chmod +x jekyll.sh
|
|
||||||
|
|
||||||
# expose port for `jekyll serve`
|
# expose port for `jekyll serve`
|
||||||
EXPOSE 4000
|
EXPOSE 4000
|
||||||
|
@ -18,9 +16,17 @@ EXPOSE 4000
|
||||||
# volume definitions
|
# volume definitions
|
||||||
VOLUME ["/mnt"]
|
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 && \
|
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
|
# run command
|
||||||
CMD ./jekyll.sh
|
CMD bundle exec jekyll serve --host=0.0.0.0 --incremental
|
|
@ -10,4 +10,6 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- 127.0.0.1:4000:4000
|
- 127.0.0.1:4000:4000
|
||||||
environment:
|
environment:
|
||||||
- JEKYLL_SITE=docs
|
- JEKYLL_SITE=docs
|
||||||
|
- USER_ID=1000
|
||||||
|
- GROUP_ID=1000
|
Reference in New Issue