updated container (first working version)
This commit is contained in:
parent
55b15f7fbd
commit
d659b37a20
23
Dockerfile
23
Dockerfile
|
@ -1,6 +1,6 @@
|
|||
# Dockerfile to build and serve a jekyll site with the development webserver
|
||||
FROM ubuntu:focal
|
||||
LABEL Description="This image is used to learn building dockerfiles" \
|
||||
LABEL Description="This image is used build and serve jekyll sites" \
|
||||
Author="david@socialnerds.org" \
|
||||
Version="0.1" \
|
||||
License="MIT"
|
||||
|
@ -9,24 +9,25 @@ LABEL Description="This image is used to learn building dockerfiles" \
|
|||
ENV JEKYLL_SITE=default
|
||||
ENV USER_ID=1000
|
||||
ENV GROUP_ID=1000
|
||||
ENV USERNAME=jekyll-dev
|
||||
|
||||
# expose port for `jekyll serve`
|
||||
# expose port for jekyll development webserver
|
||||
EXPOSE 4000
|
||||
|
||||
# volume definitions
|
||||
VOLUME ["/mnt"]
|
||||
|
||||
# prepare the baseimage and create
|
||||
# prepare the baseimage
|
||||
RUN apt-get update && apt-get install -y ruby ruby-dev gcc g++ make libssl-dev libreadline-dev && \
|
||||
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
|
||||
groupadd -g $GROUP_ID $USERNAME && \
|
||||
useradd -u $USER_ID -g $GROUP_ID -m -d /home/$USERNAME -s /bin/false $USERNAME
|
||||
|
||||
USER jekyll-dev
|
||||
# copy jekyll script into the image
|
||||
COPY jekyll.sh /opt/jekyll.sh
|
||||
|
||||
RUN cd /mnt && \
|
||||
if [ ! -d "/mnt/$JEKYLL_SITE" ]; then jekyll new $JEKYLL_SITE; fi && \
|
||||
cd $JEKYLL_SITE && bundle install
|
||||
# set executing user name
|
||||
USER $USERNAME
|
||||
|
||||
# run command
|
||||
CMD bundle exec jekyll serve --host=0.0.0.0 --incremental
|
||||
# run jekyll script
|
||||
CMD bash /opt/jekyll.sh
|
31
README.md
31
README.md
|
@ -2,3 +2,34 @@
|
|||
|
||||
Simple container to build and serve a jekyll site.
|
||||
|
||||
## Use
|
||||
|
||||
```bash
|
||||
# clone repository
|
||||
git clone https://socialg.it/david/jekyll-dev.git
|
||||
cd jekyll-dev
|
||||
|
||||
# edit to your needs
|
||||
vim docker-compose.yml
|
||||
|
||||
# build and run container
|
||||
docker-compose build
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
## Update
|
||||
|
||||
```bash
|
||||
cd jekyll-dev
|
||||
docker-compose pull && docker-compose build
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
## Remove
|
||||
|
||||
```bash
|
||||
cd jekyll-dev
|
||||
docker-compose down
|
||||
cd ..
|
||||
rm -rf jekyll-dev
|
||||
```
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
# set $PATH
|
||||
export PATH=$PATH:$HOME/.gem/bin
|
||||
|
||||
# create new jekyll site if the destination directory it does not exist
|
||||
if [ ! -d "/mnt/$JEKYLL_SITE" ]; then
|
||||
cd /mnt
|
||||
jekyll new $JEKYLL_SITE
|
||||
cd $JEKYLL_SITE
|
||||
bundle install --path $HOME/.gem
|
||||
fi
|
||||
|
||||
# build and serve
|
||||
cd /mnt/$JEKYLL_SITE
|
||||
bundle exec jekyll serve --host=0.0.0.0 --incremental
|
Reference in New Issue