Skip to content

Commit

Permalink
Process and docs for running with Docker/OpenShift
Browse files Browse the repository at this point in the history
Fix the Dockerfile so that it works both locally on a user's laptop and
in OpenShift. Add documentation in README.md on how to use the new
updated Dockerfile to run a Docker container locally or in OpenShift.


Former-commit-id: e602273
  • Loading branch information
rlaurika committed Dec 20, 2018
1 parent 1dc8253 commit a916c81
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 4 deletions.
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ ENV ROOT_GROUP_DIRS='/var/run /var/log/nginx /var/lib/nginx'

RUN yum -y install epel-release &&\
yum -y install nginx python-pip python &&\
yum clean all &&\
chmod g+rwx /var/run /var/log/nginx
yum clean all

RUN chgrp -R root ${ROOT_GROUP_DIRS} &&\
chmod -R g+rwx ${ROOT_GROUP_DIRS}
Expand All @@ -18,7 +17,6 @@ COPY . /tmp
WORKDIR /tmp

RUN pip install --no-cache-dir -r requirements.txt && \
sh -c /tmp/make_config.sh && \
mkdocs build -d /usr/share/nginx/html

COPY nginx.conf /etc/nginx
Expand Down
75 changes: 74 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,74 @@
# csc-user-guide
# CSC user guides

## Editing the documentation

The guide is written using the [Markdown markup
language](https://en.wikipedia.org/wiki/Markdown).
[MkDocs](http://www.mkdocs.org/) is used to generate static documentation pages
out of the Markdown files.

Markdown can be edited using any text editor, but you will need to install
MkDocs if you wish to preview your changes while editing your documentation. You
can find installation instructions in the [MkDocs
documentation](http://www.mkdocs.org/#installation).

You can start a preview web server from the command line
while in the root of the project directory:

```bash
mkdocs serve
```

This will start a web server on your computer listening on port 8000. Point your
web server to [localhost:8000](http://localhost:8000) to get a preview of the
documentation.

The configuration for MkDocs is in the mkdocs.yml file in the root of this
repository. The name of the documentation site, the structure of the
documentation pages and the theme to use for the site are described in this
document.

The documentation files themselves are under the docs directory.

## Using the included Dockerfile

You can also create a Docker container to host the docs. First build an image
from the included Dockerfile:

```bash
sudo docker build -t csc-user-guides .
```

This will build a container image called "csc-user-guides". Once the image is
built, you can run it like this:

```bash
sudo docker run --rm -it -p 80:8000 --name csc-user-guides csc-user-guides
```

This will run a web server on your laptop in port 80. You can view the content
of the user guides by pointing your browser to [localhost](http://localhost).

## Hosting on OpenShift

The Dockerfile is also made to be compatible with OpenShift, so it should work
with the source-to-image mechanism when using `oc new-app`. First create a new
project to host the user guide:

```bash
oc new-project my-user-guide-project
```

Note that the name of the project must be unique within the OpenShift cluster
you are running this in. Someone else may have already taken
`my-user-guide-project`.

You can then run `oc new-app` to create the user guide deployment:

```bash
oc new-app https://github.com/CSCfi/csc-user-guide#master
```

In the command above, the `#master` at the end specifies the branch to use. If
you have a feature branch that you would like to test on OpenShift, you can
specify a branch different from master.
92 changes: 92 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/

#user nginx;
worker_processes auto;
daemon off;
error_log stderr;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
worker_connections 1024;
}

http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

include /etc/nginx/mime.types;
default_type application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;

server {
listen 8000 default_server;
try_files $uri $uri/ =404;
server_name _;
absolute_redirect off;
server_name_in_redirect off;
port_in_redirect off;
root /usr/share/nginx/html;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location / {
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }

}

0 comments on commit a916c81

Please sign in to comment.