Skip to content

Commit

Permalink
Finished atomic app setup for atomic-site.
Browse files Browse the repository at this point in the history
  • Loading branch information
jberkus committed Mar 2, 2016
1 parent a9da7aa commit ff8bf80
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 6 deletions.
44 changes: 41 additions & 3 deletions BUILD.md
Expand Up @@ -3,10 +3,48 @@
This website is built on Middleman, a static site generator. See below for
instructions for building it.

## Atomic.app

The recommended way to test the site is with [atomic.app](https://github.com/projectatomic/atomicapp). Currently,
verion 0.4.2 or later is required.

### First time setup

There are a few setup steps you need to do the first time you clone
the repository and run this as an atomic app. You should have to do these again
unless you re-clone the repo for some reason.

1. authorize directory sharing in SELinux (may not be required in a VM):

```
./selinux_share.sh
```

2. configure answers.conf by copying Nulecule/answers.conf.sample to answers.conf
and editing the contents.

For answers.conf, the two things you are required to set is the full file paths
to the two directories, /source and /data. The other fields should not require
modification for most people.

### running the atomic.app

Once you've done the setup, you should be able to do this to run the container
each time and test the atomic site by running from the repository root:

```
sudo atomicpp run Nulecule/
```

The first time you do this, it will pull the atomic-site image, which may take
a while depending on your internet connection. After that it should be very fast.

Once it's running, you can view the site on [127.0.0.1:4567](http://127.0.0.1:4567)

## Docker build

The recommended way to build the site is the simplest. From the code root directory,
run the docker build:
The second way to build the site is using Docker without atomic.app From the code
root directory, run the docker build:

```
./docker.sh
Expand All @@ -22,7 +60,7 @@ time it runs. This may take a significant amount of time on slower machines.

## Manual Build

If you don't want to use the Docker container for some reason,
If you don't want to use the Atomic App or Docker containers for some reason,
instructions for a manual build follow.

To get started, you need to have Ruby and Ruby Gems installed, as well
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile
Expand Up @@ -5,7 +5,7 @@ RUN yum upgrade -y
RUN yum install -y tar libcurl-devel zlib-devel patch rubygem-bundler ruby-devel git make gcc gcc-c++

ADD config.rb /tmp/config.rb
ADD data /tmp/data
#ADD data /tmp/data
ADD Gemfile /tmp/Gemfile
ADD Gemfile.lock /tmp/Gemfile.lock
ADD lib /tmp/lib
Expand All @@ -16,4 +16,3 @@ RUN bundle install
EXPOSE 4567
ENTRYPOINT [ "bundle", "exec" ]
CMD [ "middleman", "server" ]

9 changes: 9 additions & 0 deletions Nulecule/Dockerfile
@@ -0,0 +1,9 @@
FROM projectatomic/atomicapp:0.4.2

MAINTAINER Red Hat, Inc. <container-tools@redhat.com>

LABEL io.projectatomic.nulecule.providers="kubernetes,docker" \
io.projectatomic.nulecule.specversion="0.0.2"

ADD /Nulecule /Dockerfile README.md /application-entity/
ADD /artifacts /application-entity/artifacts
24 changes: 24 additions & 0 deletions Nulecule/Nulecule
@@ -0,0 +1,24 @@
---
specversion: 0.0.2
id: atomic-site

metadata:
name: Atomic Site app
appversion: 0.0.2
description: Atomic app for testing the Atomic Website
graph:
- name: atomic-site
params:
- name: image
description: The webserver image
default: jberkus/atomic-site
- name: hostport
description: The host TCP port as the external endpoint
default: 4567
- name: sourcedir
description: location of the middleman source directory
- name: datadir
description: the middleman data directory
artifacts:
docker:
- file://artifacts/docker/atomic-site-run
32 changes: 32 additions & 0 deletions Nulecule/README.md
@@ -0,0 +1,32 @@
# atomic-site atomic app

This directory contains the configuration files for running the atomic-site
as an atomic app. The guide to bringing it up is in BUILD.md in the main directory.
What's in this file is some additional information about the atomic app setup
for this application.

## providers

Currently only the Docker provider is defined for atomic-site. PRs for
other providers are more than welcome.

## answers.conf

Here are the current parameters in the answers.conf file, and what they mean:

* **image**: the usual, currently jberkus/atomic-site until projectatomic/atomic-site goes up
* **hostport**: the port to map to on the host, default 4567
* **sourcedir**: the full path to the directory of /source in your clone of
the atomic-site repository
* **datadir**: the full path to the directory of /data in your clone of the
atomic-site repository

## volumes

Both /source and /data are mounted as volumes. This allows you to branch and edit
contents of the atomic site and see the results in the displayed webpage.

## autoremove

Currently, under the Docker provider, atomic-site is set up to autoremove the container
when you exit.
8 changes: 8 additions & 0 deletions Nulecule/answers.conf.sample
@@ -0,0 +1,8 @@
[atomic-site]
image = jberkus/atomic-site
hostport = 4567
sourcedir = /home/josh/git/redhat/atomic-site-master/source
datadir = /home/josh/git/redhat/atomic-site-master/data
[general]
namespace = default
provider = docker
1 change: 1 addition & 0 deletions Nulecule/artifacts/docker/.atomic-site-run
@@ -0,0 +1 @@
docker run --rm -p 4567:4567 --volume /home/josh/git/redhat/atomic-site-master/source:/tmp/source --volume /home/josh/git/redhat/atomic-site-master/data:/tmp/data jberkus/atomic-site
1 change: 1 addition & 0 deletions Nulecule/artifacts/docker/atomic-site-run
@@ -0,0 +1 @@
docker run --rm -p $hostport:4567 --volume $sourcedir:/tmp/source --volume $datadir:/tmp/data $image
3 changes: 2 additions & 1 deletion docker.sh
Expand Up @@ -4,7 +4,8 @@

# set SElinux context to allow docker to read the source directory
chcon -Rt svirt_sandbox_file_t source/
chcon -Rt svirt_sandbox_file_t data/

# requires docker and being in the right group
docker build -t middleman .
docker run -p 4567:4567 -v "$(pwd)"/source:/tmp/source:ro middleman
docker run --rm -p 4567:4567 -v "$(pwd)"/source:/tmp/source:ro -v "$(pwd)"/data:/tmp/data middleman
7 changes: 7 additions & 0 deletions selinux_share.sh
@@ -0,0 +1,7 @@
#/bin/bash

#tell SELinux to share the Data and Source directories
#with the container

chcon -Rt svirt_sandbox_file_t source/
chcon -Rt svirt_sandbox_file_t data/

0 comments on commit ff8bf80

Please sign in to comment.