Skip to content

Commit

Permalink
Simplified usage
Browse files Browse the repository at this point in the history
  • Loading branch information
someth2say committed Mar 23, 2020
1 parent 859b5f9 commit 658e78e
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 48 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssh/*
57 changes: 10 additions & 47 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,55 +1,18 @@
FROM registry.fedoraproject.org/fedora:30 as flamel

MAINTAINER Fernando Lozano <[email protected]>
FROM quay.io/flozanorht/flamel:0.3-7 as pre-commit

# Adding "-subrelease" to packages, such as SLIDES="-1.2.0-1", breaks the build.
# Having the dash as part of each version string allows installing whatever is latest by default, or forcing the build to use a fixed release
RUN curl https://pre-commit.com/install-local.py | python - & \
ln -s /root/bin/pre-commit /usr/bin/pre-commit & \
dnf install -y perl ruby

ARG CURRICULUM="-22-1"
ARG BRANDING
ARG FLAMEL
ARG SLIDES
ARG BOOKDIR="/tmp/coursebook"

# Make sure we get English error messages to share with the team.

ENV LANG="en_US.utf-8" \
BOOK="${BOOKDIR}"

RUN curl http://wiki.gls.redhat.com/curriculum-repos/fedora/30/x86_64/curriculum-release-fedora${CURRICULUM}.fc30.noarch.rpm -o /tmp/curriculum-release-fedora${CURRICULUM}.fc30.noarch.rpm \
&& dnf -y install /tmp/*rpm \
&& rm -f /tmp/*rpm \
&& dnf --nodocs -y install \
publican-gls-redhat-new redhat-training-xsl${BRANDING} reveal-js-slide-generator${SLIDES} \
interstate-fonts overpass-fonts flamel${FLAMEL} git \
&& dnf clean all \
&& mkdir -p ${BOOK}

COPY check-gls-packages.sh /tmp

VOLUME ${BOOK}
FROM pre-commit

WORKDIR ${BOOK}/guides

# Install pre-commit in a separate container.

FROM flamel as pre-commit

RUN pip install --upgrade pip &&\
pip install --upgrade wheel setuptools &&\
pip install pre-commit

# Install additional packages and interpreters
FROM pre-commit as pre-commit-hooks
ARG BOOKDIR="/tmp/coursebook"

RUN dnf install -y perl ruby
ENV LANG="en_US.utf-8"

# Setup ssh identities
FROM pre-commit-hooks
ENTRYPOINT ["pre-commit"]

RUN mkdir /root/.ssh
#COPY ssh /root/.ssh
RUN chmod 0400 /root/.ssh/*
WORKDIR ${BOOK}
WORKDIR ${BOOKDIR}

CMD ["pre-commit","run","-a"]
CMD ["run","-a"]
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
Docker image for running GLS pre-commit hooks.
Docker image for running GLS pre-commit hooks.

Usage:
Just run "pre-commit.sh" or alias it to "pre-commit" in your system.

If your SSH configuration or your pre-commit cache is not in the default locations, update the appropriate variables in the "pre-commit.sh" script file as needed.
18 changes: 18 additions & 0 deletions pre-commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#! /bin/sh

image=quay.io/someth2say/pre-commit:0.1.0

book=$(pwd)
container_book=/tmp/coursebook

ssh_cfg=~/.ssh
container_ssh_cfg=/root/.ssh

pcommit_cache=~/.cache/pre-commit
containe_pcommit_cache=/root/.cache/pre-commit

docker run \
-v ${ssh_cfg}:${container_ssh_cfg} \
-v ${pcommit_cache}:${containe_pcommit_cache}:z \
-v ${book}:${container_book}:z \
${image} $@

0 comments on commit 658e78e

Please sign in to comment.