Part of #1 Reviewed-on: #2 Co-authored-by: Benoit Donneaux <benoit@leastauthority.com> Co-committed-by: Benoit Donneaux <benoit@leastauthority.com>
This commit is contained in:
parent
6716049676
commit
097fc8acc6
|
@ -0,0 +1,45 @@
|
||||||
|
name: Jekyll
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
env:
|
||||||
|
_UID: 1000
|
||||||
|
_GID: 1000
|
||||||
|
jobs:
|
||||||
|
jekyll:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
id: checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Change file ownership
|
||||||
|
id: file_ownership
|
||||||
|
run: |
|
||||||
|
chown -R ${_UID}:${_GID} .
|
||||||
|
- name: Install docker
|
||||||
|
id: install_docker
|
||||||
|
run: |
|
||||||
|
apt-get -q update
|
||||||
|
apt-get -q install -y docker-compose
|
||||||
|
apt-get -q clean
|
||||||
|
- name: Verify docker
|
||||||
|
id: verify_docker
|
||||||
|
run: |
|
||||||
|
docker run --rm hello-world:latest > /dev/null
|
||||||
|
docker rmi hello-world:latest > /dev/null
|
||||||
|
docker version
|
||||||
|
docker-compose version
|
||||||
|
docker volume ls
|
||||||
|
- name: Build Jekyll image
|
||||||
|
id: build_image
|
||||||
|
run: |
|
||||||
|
# The environment variables _UID and _GID can impact this image
|
||||||
|
docker-compose build jekyll
|
||||||
|
- name: Build Jekyll site
|
||||||
|
id: build_site
|
||||||
|
run: |
|
||||||
|
docker-compose run --rm -v "${JOB_CONTAINER_NAME}:/site" -w /site \
|
||||||
|
jekyll build --verbose
|
|
@ -5,17 +5,18 @@ services:
|
||||||
context: docker/jekyll
|
context: docker/jekyll
|
||||||
args:
|
args:
|
||||||
uid: "${_UID:-1000}"
|
uid: "${_UID:-1000}"
|
||||||
|
user: "${_USER:-appuser}"
|
||||||
gid: "${_GID:-1000}"
|
gid: "${_GID:-1000}"
|
||||||
|
group: "${_GROUP:-appgroup}"
|
||||||
volumes:
|
volumes:
|
||||||
- .:/home/jekyll/workspace
|
- .:/appdata
|
||||||
working_dir: /home/jekyll/workspace
|
working_dir: /appdata
|
||||||
ports:
|
ports:
|
||||||
- "4000:4000"
|
- "4000:4000"
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
tty: true
|
tty: true
|
||||||
hostname: jekyll.local
|
hostname: jekyll.local
|
||||||
container_name: jekyll.local
|
container_name: jekyll.local
|
||||||
command: bash
|
|
||||||
networks:
|
networks:
|
||||||
- bridge
|
- bridge
|
||||||
deploy:
|
deploy:
|
||||||
|
|
|
@ -10,14 +10,15 @@ RUN INSTALL_PKGS="gcc g++ libyaml-dev make nodejs" && \
|
||||||
|
|
||||||
# Parameters for default user:group
|
# Parameters for default user:group
|
||||||
ARG uid=1000
|
ARG uid=1000
|
||||||
ARG user=ubuntu
|
ARG user=appuser
|
||||||
ARG gid=1000
|
ARG gid=1000
|
||||||
ARG group=ubuntu
|
ARG group=appgroup
|
||||||
|
|
||||||
# Add or modify user and group for build and runtime (convenient)
|
# Ensure desired user and group for build and runtime (convenient)
|
||||||
#RUN id ${user} > /dev/null 2>&1 && \
|
RUN userdel --force --remove $(getent passwd ${uid} | cut -d: -f1) || true; \
|
||||||
# { groupmod -g "${gid}" "${group}" && usermod -md /home/${user} -s /bin/bash -g "${group}" -u "${uid}" "${user}"; } || \
|
groupdel $(getent group ${gid} | cut -d: -f1) || true; \
|
||||||
# { groupadd -g "${gid}" "${group}" && useradd -md /home/${user} -s /bin/bash -g "${group}" -u "${uid}" "${user}"; }
|
groupadd -g "${gid}" "${group}" && \
|
||||||
|
useradd -md /home/${user} -s /bin/bash -g "${group}" -u "${uid}" "${user}";
|
||||||
|
|
||||||
# Copy requirements in non-root user home directory
|
# Copy requirements in non-root user home directory
|
||||||
COPY Gemfile Gemfile.lock "/home/${user}/"
|
COPY Gemfile Gemfile.lock "/home/${user}/"
|
||||||
|
@ -25,17 +26,18 @@ RUN chown "${user}:${group}" "/home/${user}/Gemfile"*
|
||||||
|
|
||||||
# Switch to non-root user
|
# Switch to non-root user
|
||||||
USER ${user}
|
USER ${user}
|
||||||
WORKDIR /home/${user}
|
WORKDIR /appdata
|
||||||
|
|
||||||
# Install required gems
|
# Install required gems
|
||||||
RUN echo "gem: --no-document --user-install --bindir /home/${user}/bin" >> /home/${user}/.gemrc && \
|
RUN echo "gem: --no-document --user-install --bindir /home/${user}/bin" >> /home/${user}/.gemrc && \
|
||||||
echo "gempath: /home/${user}/.gem/ruby:/home/${user}/.bundle/gems/ruby/3.3.0" >> .gemrc && \
|
echo "gempath: /home/${user}/.gem/ruby:/home/${user}/.bundle/gems/ruby/3.3.0" >> /home/${user}/.gemrc && \
|
||||||
gem install bundler --version `sed -n -r -e '/BUNDLED WITH/,$ { s/\s+([.0-9]+)/\1/ p }' Gemfile.lock` && \
|
gem install bundler --version `sed -n -r -e '/BUNDLED WITH/,$ { s/\s+([.0-9]+)/\1/ p }' /home/${user}/Gemfile.lock` && \
|
||||||
bundle config --global path /home/${user}/.bundle/gems && \
|
bundle config --global path /home/${user}/.bundle/gems && \
|
||||||
bundle config --global bin /home/${user}/bin && \
|
bundle config --global bin /home/${user}/bin && \
|
||||||
bundle install && \
|
bundle install --gemfile=/home/${user}/Gemfile && \
|
||||||
rm -rf /home/${user}/.bundle/cache
|
rm -rf /home/${user}/.bundle/cache
|
||||||
|
|
||||||
ENV PATH=/home/${user}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
ENV PATH=/home/${user}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
|
||||||
CMD [ 'jekyll', 's', 'source', './src', '--verbose', '--host 0.0.0.0', '--incremental' ]
|
ENTRYPOINT ["jekyll"]
|
||||||
|
CMD ["server", "--verbose", "--host", "0.0.0.0", "--incremental"]
|
||||||
|
|
Loading…
Reference in New Issue