diff --git a/devfile.yaml b/.devfile.yaml similarity index 59% rename from devfile.yaml rename to .devfile.yaml index cd94c731..8baf5f79 100644 --- a/devfile.yaml +++ b/.devfile.yaml @@ -1,4 +1,4 @@ -schemaVersion: 2.1.0 +schemaVersion: 2.2.0 metadata: name: che-blog components: @@ -6,6 +6,9 @@ components: container: image: quay.io/eclipse/che-blog:next memoryLimit: 4Gi + cpuLimit: '2' + memoryRequest: 1Gi + cpuRequest: 500m endpoints: - exposure: public name: live-reload @@ -16,18 +19,27 @@ components: protocol: http targetPort: 4000 commands: - - id: jekyll-clean + - id: bundle-install exec: + label: 0. Install Gemfile dependencies component: jekyll - commandLine: bundle jekyll clean + commandLine: bundle install group: - kind: run + kind: build isDefault: true - id: start-jekyll-server exec: + label: 1. Start the jekyll based blog server component: jekyll # commandLine: bundle jekyll serve --incremental --watch --host 0.0.0.0 --livereload --livereload-port 35729 - commandLine: bundle jekyll serve --incremental --watch --host 0.0.0.0 + commandLine: bundle exec jekyll serve --incremental --watch --host 0.0.0.0 group: kind: run isDefault: true + - id: jekyll-clean + exec: + component: jekyll + commandLine: bundle exec jekyll clean + group: + kind: build + isDefault: false diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 880a2387..4d161007 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -1,5 +1,5 @@ # -# Copyright (c) 2021 Red Hat, Inc. +# Copyright (c) 2023 Red Hat, Inc. # This program and the accompanying materials are made # available under the terms of the Eclipse Public License 2.0 # which is available at https://www.eclipse.org/legal/epl-2.0/ @@ -21,23 +21,40 @@ RUN wget -qO- https://github.com/errata-ai/vale/archive/v${VALE_VERSION}.tar.gz && GOOS=linux GOARCH=${ARCH} CGO_ENABLED=0 go build -tags closed -ldflags "-X main.date=`date -u +%Y-%m-%dT%H:%M:%SZ` -X main.version=${VALE_VERSION}" -o bin/vale ./cmd/vale \ && /vale/bin/vale --version -# use jekyll image -FROM docker.io/jekyll/jekyll:4.2.2 +# use UBI image +FROM quay.io/devfile/universal-developer-image:latest + COPY --from=vale-builder /vale/bin/vale /usr/local/bin/vale -RUN mkdir -p /home/jekyll/.vale/styles -WORKDIR /home/jekyll/.vale/styles -RUN wget -qO- https://github.com/redhat-documentation/vale-at-red-hat/releases/latest/download/RedHat.zip | unzip - -RUN wget -qO- https://github.com/eclipse-che/che-docs-vale-style/releases/latest/download/CheDocs.zip | unzip - -COPY --chown=jekyll:jekyll .docker/.vale.ini /home/jekyll/.vale.ini -COPY --chown=jekyll:jekyll Gemfile . -COPY --chown=jekyll:jekyll Gemfile.lock . -RUN bundle install -COPY --chown=0:0 .docker/entrypoint.sh / -RUN chgrp -R 0 /home && chmod -R g=u /etc/passwd /etc/group /home && chmod +x /entrypoint.sh && usermod --shell /bin/bash jekyll - -USER 1000 -WORKDIR /projects -ENV HOME=/home/jekyll -ENV USER_NAME=jekyll -ENTRYPOINT [ "/entrypoint.sh" ] -CMD ["tail", "-f", "/dev/null"] +RUN mkdir -p $HOME/.vale/styles && \ + cd $HOME/.vale/styles && \ + curl -sSL -o ./RedHat.zip https://github.com/redhat-documentation/vale-at-red-hat/releases/latest/download/RedHat.zip && \ + curl -sSL -o ./CheDocs.zip https://github.com/eclipse-che/che-docs-vale-style/releases/latest/download/CheDocs.zip && \ + unzip ./RedHat.zip && rm ./RedHat.zip && \ + unzip ./CheDocs.zip && rm ./CheDocs.zip +COPY --chown=user:0 .docker/.vale.ini $HOME/.vale.ini + +# The following commands require root +USER 0 + +# Install a recent version of ruby +ENV RUBY_VERSION 3.1.2 +RUN dnf -y update && \ + dnf -y install rbenv ruby-build sqlite && \ + dnf -y clean all --enablerepo='*' && \ + rbenv install $RUBY_VERSION && \ + rbenv global $RUBY_VERSION && \ + echo 'eval "$(rbenv init - bash)"' >> $HOME/.bashrc && \ + echo 'eval "$(rbenv init - sh)"' > /etc/profile.d/rbenv.sh + +ENV PATH="${HOME}/.rbenv/shims:${PATH}" ENV="/etc/profile" + +# Install jekyll +RUN gem install jekyll + +# Set bundle config +RUN bundle config --global path $HOME/.bundle/vendor && \ + chgrp -R 0 $HOME/.bundle && chmod -R g=u $HOME/.bundle && \ + chgrp -R 0 $HOME/.local && chmod -R g=u $HOME/.local && \ + chgrp -R 0 $HOME/.rbenv && chmod -R g=u $HOME/.rbenv + +USER 10001 diff --git a/.docker/entrypoint.sh b/.docker/entrypoint.sh deleted file mode 100644 index ace464b0..00000000 --- a/.docker/entrypoint.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2021 Red Hat, Inc. -# This program and the accompanying materials are made -# available under the terms of the Eclipse Public License 2.0 -# which is available at https://www.eclipse.org/legal/epl-2.0/ -# -# SPDX-License-Identifier: EPL-2.0 -# - -# Ensure $HOME exists when starting -if [ ! -d "${HOME}" ]; then - mkdir -p "${HOME}" -fi - -# Setup $PS1 for a consistent and reasonable prompt -if [ -w "${HOME}" ] && [ ! -f "${HOME}"/.bashrc ]; then - echo "PS1='\s-\v \w \$ '" > "${HOME}"/.bashrc -fi - -# Add current (arbitrary) user to /etc/passwd and /etc/group -if ! whoami &> /dev/null; then - if [ -w /etc/passwd ]; then - echo "${USER_NAME:-user}:x:$(id -u):0:${USER_NAME:-user} user:${HOME}:/bin/bash" >> /etc/passwd - echo "${USER_NAME:-user}:x:$(id -u):" >> /etc/group - fi -fi - -exec "$@"