elixir/docker/centos/Dockerfile
Michael Opdenacker 65783e715a Improve Docker scripts to support any project
- Great for testing Elixir on smaller projects

Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
2019-09-23 20:11:40 +02:00

78 lines
2.1 KiB
Docker

# Openshift Dockerfile for Centos7 Elixir Cross Referencer
# This will build a httpd 2.4.34+ service container running Elixir
# You may run this image on its own or as a component of a pod.
# Usage:
# Building: Docker Build dockerfile_path/ --build-arg GIT_REPO_URL=https://your-git-source-repo.git -t elixir
# Running: Docker run -p 8080:8080 elixir
FROM centos/httpd-24-centos7
LABEL author="David.Southwick@cern.ch"
# temporarily switch to root user
USER root
ARG GIT_REPO_URL
ARG PROJECT
RUN \
: "${GIT_REPO_URL:?set GIT_REPO_URL to the repo git url}"
RUN \
: "${PROJECT:?set PROJECT to set the project name}"
RUN \
echo "repo url to index: ${GIT_REPO_URL}"
RUN \
yum install -y \
python36-jinja2 \
python36-pygments \
python36-bsddb3 \
global-ctags \
git
# httpd & perl is inherited from upstream openshift image
RUN \
git clone https://github.com/bootlin/elixir.git /usr/local/elixir/
RUN \
mkdir -p /srv/elixir-data/$PROJECT/repo && \
mkdir -p /srv/elixir-data/$PROJECT/data && \
git clone "${GIT_REPO_URL}" /srv/elixir-data/$PROJECT/repo/
ENV LXR_REPO_DIR /srv/elixir-data/$PROJECT/repo
ENV LXR_DATA_DIR /srv/elixir-data/$PROJECT/data
RUN \
cd /usr/local/elixir/ && \
./script.sh list-tags && \
./update.py
# apache elixir config, see elixir README
# apache HttpProtolOptions workaround
RUN \
echo $'<Directory /usr/local/elixir/http/>\n\
Options +ExecCGI\n\
AllowOverride None\n\
Require all granted\n\
SetEnv PYTHONIOENCODING utf-8\n\
SetEnv LXR_PROJ_DIR /srv/elixir-data\n\
</Directory>\n\
AddHandler cgi-script .py\n\
<VirtualHost *:8080>\n\
ServerName MY_LOCAL_IP\n\
DocumentRoot /usr/local/elixir/http\n\
RewriteEngine on\n\
RewriteRule "^/$" "/$PROJECT/latest/source" [R]\n\
RewriteRule "^/.*/(source|ident|search)" "/web.py" [PT]\n\
</VirtualHost>' > /etc/httpd/conf.d/000-elixir.conf \
&& echo -e "\nHttpProtocolOptions Unsafe" >> /etc/httpd/conf/httpd.conf
# a2enmod cgi rewrite - enabled by default in RHEL/centos
# Make sure the final image runs as unprivileged user
USER 1001
ENTRYPOINT ["/usr/bin/run-httpd"]