Improve Docker scripts to support any project

- Great for testing Elixir on smaller projects

Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
This commit is contained in:
Michael Opdenacker 2019-09-23 20:11:40 +02:00
parent fb5bda5584
commit 65783e715a
3 changed files with 30 additions and 15 deletions

View file

@ -131,10 +131,18 @@ Building Docker images
---------------------- ----------------------
Docker files are provided in the "docker/" directory. To generate your own Docker files are provided in the "docker/" directory. To generate your own
Docker image for indexing the Linux kernel sources (for example), Docker image for indexing the sources of a project (for example for the Musl
download the "Dockerfile" file for your target distribution and run: project which is much faster to index that Linux), download the "Dockerfile"
file for your target distribution and run:
$ docker build -t elixir --build-arg GIT_REPO_URL=git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git . $ docker build -t elixir --build-arg GIT_REPO_URL=git://git.musl-libc.org/musl --build-arg PROJECT=musl .
Then you can use your new container as follows (you get the container id from the output of "docker build"):
$ docker run <container-id>
You can the open the below URL in a browser on your host: http://172.17.0.2/musl/latest/source
(change the container IP address if you don't get the default one)
Hardware requirements Hardware requirements
--------------------- ---------------------

View file

@ -13,10 +13,14 @@ LABEL author="David.Southwick@cern.ch"
USER root USER root
ARG GIT_REPO_URL ARG GIT_REPO_URL
ARG PROJECT
RUN \ RUN \
: "${GIT_REPO_URL:?set GIT_REPO_URL to the repo git url}" : "${GIT_REPO_URL:?set GIT_REPO_URL to the repo git url}"
RUN \
: "${PROJECT:?set PROJECT to set the project name}"
RUN \ RUN \
echo "repo url to index: ${GIT_REPO_URL}" echo "repo url to index: ${GIT_REPO_URL}"
@ -34,12 +38,12 @@ RUN \
git clone https://github.com/bootlin/elixir.git /usr/local/elixir/ git clone https://github.com/bootlin/elixir.git /usr/local/elixir/
RUN \ RUN \
mkdir -p /srv/elixir-data/linux/repo && \ mkdir -p /srv/elixir-data/$PROJECT/repo && \
mkdir -p /srv/elixir-data/linux/data && \ mkdir -p /srv/elixir-data/$PROJECT/data && \
git clone "${GIT_REPO_URL}" /srv/elixir-data/linux/repo/ git clone "${GIT_REPO_URL}" /srv/elixir-data/$PROJECT/repo/
ENV LXR_REPO_DIR /srv/elixir-data/linux/repo ENV LXR_REPO_DIR /srv/elixir-data/$PROJECT/repo
ENV LXR_DATA_DIR /srv/elixir-data/linux/data ENV LXR_DATA_DIR /srv/elixir-data/$PROJECT/data
RUN \ RUN \
cd /usr/local/elixir/ && \ cd /usr/local/elixir/ && \
@ -47,7 +51,6 @@ RUN \
./update.py ./update.py
# apache elixir config, see elixir README # apache elixir config, see elixir README
# NB: Change /linux/ to the name of the project you want as default shown
# apache HttpProtolOptions workaround # apache HttpProtolOptions workaround
RUN \ RUN \
echo $'<Directory /usr/local/elixir/http/>\n\ echo $'<Directory /usr/local/elixir/http/>\n\
@ -62,7 +65,7 @@ AddHandler cgi-script .py\n\
ServerName MY_LOCAL_IP\n\ ServerName MY_LOCAL_IP\n\
DocumentRoot /usr/local/elixir/http\n\ DocumentRoot /usr/local/elixir/http\n\
RewriteEngine on\n\ RewriteEngine on\n\
RewriteRule "^/$" "/linux/latest/source" [R]\n\ RewriteRule "^/$" "/$PROJECT/latest/source" [R]\n\
RewriteRule "^/.*/(source|ident|search)" "/web.py" [PT]\n\ RewriteRule "^/.*/(source|ident|search)" "/web.py" [PT]\n\
</VirtualHost>' > /etc/httpd/conf.d/000-elixir.conf \ </VirtualHost>' > /etc/httpd/conf.d/000-elixir.conf \
&& echo -e "\nHttpProtocolOptions Unsafe" >> /etc/httpd/conf/httpd.conf && echo -e "\nHttpProtocolOptions Unsafe" >> /etc/httpd/conf/httpd.conf

View file

@ -1,9 +1,13 @@
FROM debian:latest FROM debian:latest
ARG GIT_REPO_URL ARG GIT_REPO_URL
ARG PROJECT
RUN \ RUN \
: "${GIT_REPO_URL:?set GIT_REPO_URL to the repo git url}" : "${GIT_REPO_URL:?set GIT_REPO_URL to the repo git url}"
RUN \
: "${PROJECT:?set PROJECT to set the project name}"
RUN \ RUN \
echo "repo url to index: ${GIT_REPO_URL}" echo "repo url to index: ${GIT_REPO_URL}"
@ -26,12 +30,12 @@ RUN \
mkdir -p /srv/elixir-data/ mkdir -p /srv/elixir-data/
RUN \ RUN \
mkdir -p /srv/elixir-data/linux/repo && \ mkdir -p /srv/elixir-data/$PROJECT/repo && \
mkdir -p /srv/elixir-data/linux/data && \ mkdir -p /srv/elixir-data/$PROJECT/data && \
git clone "${GIT_REPO_URL}" /srv/elixir-data/linux/repo/ git clone "${GIT_REPO_URL}" /srv/elixir-data/$PROJECT/repo/
ENV LXR_REPO_DIR /srv/elixir-data/linux/repo ENV LXR_REPO_DIR /srv/elixir-data/$PROJECT/repo
ENV LXR_DATA_DIR /srv/elixir-data/linux/data ENV LXR_DATA_DIR /srv/elixir-data/$PROJECT/data
RUN \ RUN \
cd /usr/local/elixir/ && \ cd /usr/local/elixir/ && \