Skip to content

Commit 4184a06

Browse files
authored
Added commented code about docker permissions, organized Dockerfile (alshedivat#2801)
I am currently testing out docker in a remote lab environment where docker was configured in a way that it can't run as root, causing some permission issues. The solution I could find was to add these changes (commented by default) to these files and fill the specifics so it could run as it was your user running the code. Signed-off-by: George Araújo <[email protected]>
1 parent 613be39 commit 4184a06

File tree

2 files changed

+58
-18
lines changed

2 files changed

+58
-18
lines changed

Diff for: Dockerfile

+49-18
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,75 @@
11
FROM ruby:latest
22

3+
# uncomment these if you are having this issue with the build:
4+
# /usr/local/bundle/gems/jekyll-4.3.4/lib/jekyll/site.rb:509:in `initialize': Permission denied @ rb_sysopen - /srv/jekyll/.jekyll-cache/.gitignore (Errno::EACCES)
5+
# ARG GROUPID=901
6+
# ARG GROUPNAME=ruby
7+
# ARG USERID=901
8+
# ARG USERNAME=jekyll
9+
310
ENV DEBIAN_FRONTEND noninteractive
411

5-
Label MAINTAINER Amir Pourmand
12+
LABEL authors="Amir Pourmand,George Araújo" \
13+
description="Docker image for al-folio academic template" \
14+
maintainer="Amir Pourmand"
15+
16+
# uncomment these if you are having this issue with the build:
17+
# /usr/local/bundle/gems/jekyll-4.3.4/lib/jekyll/site.rb:509:in `initialize': Permission denied @ rb_sysopen - /srv/jekyll/.jekyll-cache/.gitignore (Errno::EACCES)
18+
# add a non-root user to the image with a specific group and user id to avoid permission issues
19+
# RUN groupadd -r $GROUPNAME -g $GROUPID && \
20+
# useradd -u $USERID -m -g $GROUPNAME $USERNAME
621

7-
RUN apt-get update -y && apt-get install -y --no-install-recommends \
8-
locales \
9-
nodejs npm \
10-
imagemagick \
11-
build-essential \
12-
zlib1g-dev \
13-
python3-pip \
14-
inotify-tools procps && \
15-
apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* && \
16-
pip install nbconvert --break-system-packages
22+
# install system dependencies
23+
RUN apt-get update -y && \
24+
apt-get install -y --no-install-recommends \
25+
build-essential \
26+
curl \
27+
imagemagick \
28+
inotify-tools \
29+
locales \
30+
nodejs \
31+
procps \
32+
python3-pip \
33+
zlib1g-dev && \
34+
pip --no-cache-dir install --upgrade --break-system-packages nbconvert
1735

36+
# clean up
37+
RUN apt-get clean && \
38+
apt-get autoremove && \
39+
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* /tmp/*
1840

41+
# set the locale
1942
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
2043
locale-gen
2144

22-
23-
ENV LANG=en_US.UTF-8 \
45+
# set environment variables
46+
ENV EXECJS_RUNTIME=Node \
47+
JEKYLL_ENV=production \
48+
LANG=en_US.UTF-8 \
2449
LANGUAGE=en_US:en \
25-
LC_ALL=en_US.UTF-8 \
26-
JEKYLL_ENV=production
50+
LC_ALL=en_US.UTF-8
2751

52+
# create a directory for the jekyll site
2853
RUN mkdir /srv/jekyll
2954

55+
# copy the Gemfile and Gemfile.lock to the image
3056
ADD Gemfile.lock /srv/jekyll
3157
ADD Gemfile /srv/jekyll
3258

59+
# set the working directory
3360
WORKDIR /srv/jekyll
3461

3562
# install jekyll and dependencies
36-
RUN gem install jekyll bundler
37-
63+
RUN gem install --no-document jekyll bundler
3864
RUN bundle install --no-cache
39-
# && rm -rf /var/lib/gems/3.1.0/cache
65+
4066
EXPOSE 8080
4167

4268
COPY bin/entry_point.sh /tmp/entry_point.sh
4369

70+
# uncomment this if you are having this issue with the build:
71+
# /usr/local/bundle/gems/jekyll-4.3.4/lib/jekyll/site.rb:509:in `initialize': Permission denied @ rb_sysopen - /srv/jekyll/.jekyll-cache/.gitignore (Errno::EACCES)
72+
# set the ownership of the jekyll site directory to the non-root user
73+
# USER $USERNAME
74+
4475
CMD ["/tmp/entry_point.sh"]

Diff for: docker-compose.yml

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ services:
33
jekyll:
44
image: amirpourmand/al-folio:v0.12.0
55
build: .
6+
# uncomment these if you are having this issue with the build:
7+
# /usr/local/bundle/gems/jekyll-4.3.4/lib/jekyll/site.rb:509:in `initialize': Permission denied @ rb_sysopen - /srv/jekyll/.jekyll-cache/.gitignore (Errno::EACCES)
8+
# and fill the args values with the output of the commands on the right
9+
# build:
10+
# args:
11+
# GROUPID: # id -g
12+
# GROUPNAME: # id -gn
13+
# USERID: # id -u
14+
# USERNAME: # echo $USER
615
ports:
716
- 8080:8080
817
- 35729:35729

0 commit comments

Comments
 (0)