Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offer Docker image, fix Teiid typos #17

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ _site

## Ruby tools
.rvmrc
.bundle
_bin

## Infinispan sources and docs
infinispan_srcs
Expand Down
37 changes: 37 additions & 0 deletions bin/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM fedora:22

# install the required dependencies to compile native extensions
# and needed by the website to fetch resources
RUN dnf -y install gcc-c++ make ruby-devel libxml2-devel libxslt-devel findutils git ruby wget

RUN groupadd -r dev && useradd -g dev -u 1000 dev && mkdir -p /home/dev && chown dev:dev /home/dev

# From here we run everything as dev user
USER dev

# Setup all the env variables needed for ruby
ENV HOME /home/dev
ENV GEM_HOME $HOME/.gems
ENV GEM_PATH $HOME/.gems
ENV PATH $PATH:$GEM_HOME/bin
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
RUN mkdir $HOME/.gems

# Install Rake and Bundler for driving the Awestruct build & site
RUN gem install -N rake bundler

# Clone infinispan.github.io in order to run the setup task
RUN git clone https://github.com/infinispan/infinispan.github.io.git $HOME/infinispan.github.io
RUN cd $HOME/infinispan.github.io && git checkout develop && rake setup

# We need to patch awestruct to make auto generation work. On mounted volumes file
# change montoring will only work with polling
RUN gem contents awestruct | grep auto.rb | xargs sed -i "s/^\(.*force_polling =\).*/\1 true/"

EXPOSE 4242
VOLUME $HOME/infinispan.github.io
WORKDIR $HOME/infinispan.github.io

CMD [ "/bin/bash" ]

134 changes: 134 additions & 0 deletions bin/docker/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
= Running infinispan.github.io within Docker

The following instructions allow you to run infinispan.github.io within
a docker container while still being able to edit your sources locally.
This is not a Docker introduction. At least you will need a running
Docker daemon. If you want an intro into Docker - link:http://docs.docker.com/[start here].

== The short version

The short version. If you are lucky all you need is:

[source]
----
# from the repository root
> cd bin/docker
> docker build -t infinispan/infinispan.github.io .
> cd ../..
> ./bin/run_docker.sh
----

Once you have a bash into the running container you can use the various Rake task to
drive awestruct and in particular `rake clean preview`

[TIP]
====
The first time you use the Docker approach make sure that you don't have any changes
in your local checkout of infinispan.github.io, in particular temp files generated by
Bundler. You can for example run `git clean -fxd`, but make sure you have no
outstanding changes.
====

[TIP]
====
On Linux you might need to use _sudo_ to execute docker commands. If you want to
avoid that have a look at link:https://docs.docker.com/installation/ubuntulinux/#create-a-docker-group[create a docker group].
====

[NOTE]
====
`run_docker.sh` tries to determine the full path to the root directory of your
infinispan.github.io checkout. It assumes you are either at the root of the repo
or in the bin directory when you execute it.
You can look at the script to run this command from anywhere.
====

== The long version

=== Building the Docker image

First step is to build the Docker image containing your awestruct setup.
This step could eventually be replaced by a automatically build image made
available via a Docker repository. For now, however, we build this image locally.

[source]
----
> docker build --no-cache=true -t infinispan/infinispan.github.io
----

Whenever the gem dependencies change, you will need to rebuild the image to make sure
you get a working environment out of the box.

Below you see the used Dockerfile with some comments:

[source]
.Dockerfile for Awestruct setup based on Fedora 22
----
FROM fedora:22

# install the required dependencies to compile native extensions
# and needed by the website to fetch resources
RUN dnf -y install gcc-c++ make ruby-devel libxml2-devel libxslt-devel findutils git ruby wget // <1>

RUN groupadd -r dev && useradd -g dev -u 1000 dev && mkdir -p /home/dev && chown dev:dev /home/dev // <2>

# From here we run everything as dev user
USER dev

# Setup all the env variables needed for ruby
ENV HOME /home/dev
ENV GEM_HOME $HOME/.gems
ENV GEM_PATH $HOME/.gems
ENV PATH $PATH:$GEM_HOME/bin
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
RUN mkdir $HOME/.gems

# Install Rake and Bundler for driving the Awestruct build & site
RUN gem install -N rake bundler

# Clone infinispan.github.io in order to run the setup task
RUN git clone https://github.com/infinispan/infinispan.github.io.git // <3>
RUN cd $HOME/infinispan.github.io && git checkout develop && rake setup

# We need to patch awestruct to make auto generation work. On mounted volumes file
# change montoring will only work with polling
RUN gem contents awestruct | grep auto.rb | xargs sed -i "s/^\(.*force_polling =\).*/\1 true/" // <4>

EXPOSE 4242
VOLUME $HOME/infinispan.github.io
WORKDIR $HOME/infinispan.github.io

CMD [ "/bin/bash" ]
----
<1> Install all dependencies, especially the ones needed to compile native
extensions. After changes to the gem dependencies this might need to be updated.
Otherwise we rely on the default ruby version available via _dnf_.
<2> In order for the container to be able to modify files in your mounted volume,
we need to make sure that the created _dev_ user gets the same user id as the files
have on the host machine. In many cases 1000 is a good guess, but in case you are
getting file permission errors when running `rake preview` you want to check which
user id the files have when mounted into the container. Use this user id as part of
the `useradd` command and re-build the image.
<3> We need the checkout to setup the awestruct environment. At runtime the checkout
will be overridden by the mounted volume
<4> An awestruct hack. Awestruct uses live-reload to determine file changes in order
to trigger re-generation of pages. live-reload allows to configure how changes are
detected, but awestruct does not expose this option. When mounting your checkout as
a volume, the default detection fails (at least on Mac using docker-machine) and polling
needs to be used. This sed command will patch the awestruct version we use. Obviously
this is very fragile to changes in awestruct version

=== Running the container

Once you have your image you can run the docker container and use it to drive your
awestruct site. The site can be previewed under http://localhost:4242 on Linux or
http://<docker-ip>:4242 with docker-machine, where _docker-ip_ can be retrieved via
`boot2docker ls`.

[source]
----
> ./bin/run_docker.sh
----


16 changes: 16 additions & 0 deletions bin/run_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# can be run form the Git repo root dir or from the repo_dir/bin directory
# author Emmanuel Bernard

# Little dance to guess if we are in the root of the repo or not
PWD="`pwd`"
DIRNAME="`dirname $PWD`"
if [[ "$DIRNAME/bin" == "$PWD" ]];
then
ROOT_DIR="`pwd | xargs dirname`"
else
ROOT_DIR="`pwd`"
fi
echo $ROOT_DIR

docker run -t -i -p 4242:4242 -v $ROOT_DIR:/home/dev/infinispan.github.io infinispan/infinispan.github.io
2 changes: 1 addition & 1 deletion references.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ title: References
Hibernate ORM has a second-level cache provider built on top of Infinispan

%a(name="teiid")
%h3 Teeid
%h3 Teiid
%p
%a(href="http://teiid.org") http://teiid.org
%p
Expand Down