[LNT] r372354 - [LNT] Add docker containerization files
Thomas Preud'homme via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 19 14:14:21 PDT 2019
Author: thopre
Date: Thu Sep 19 14:14:20 2019
New Revision: 372354
URL: http://llvm.org/viewvc/llvm-project?rev=372354&view=rev
Log:
[LNT] Add docker containerization files
LNT already strive to be easy to use both locally and in server mode.
This patch adds containerization files in a new docker/ directory (which
can later be renamed container/docker if more container gets supported).
Creating the image becomes as easy as docker-compose build and running
it is done via docker-compose up.
The service described in docker-compose.yml uses postgres but the LNT
image is controlled via DB_ variables and thus should work with any
database engine.
Note: I'm quite new to Docker so some reviews on Docker best practice
would be much welcome.
Reviewers: MatzeB, danilaml, kristof.beyls, cmatthews
Reviewed By: cmatthews
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D65794
Added:
lnt/trunk/docker/
lnt/trunk/docker/.env
lnt/trunk/docker/Dockerfile
lnt/trunk/docker/docker-compose.yml
lnt/trunk/docker/docker-entrypoint.sh (with props)
lnt/trunk/docker/wait_db (with props)
Added: lnt/trunk/docker/.env
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/docker/.env?rev=372354&view=auto
==============================================================================
--- lnt/trunk/docker/.env (added)
+++ lnt/trunk/docker/.env Thu Sep 19 14:14:20 2019
@@ -0,0 +1,2 @@
+DB_USER=lntuser
+DB_BASE=lnt
Added: lnt/trunk/docker/Dockerfile
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/docker/Dockerfile?rev=372354&view=auto
==============================================================================
--- lnt/trunk/docker/Dockerfile (added)
+++ lnt/trunk/docker/Dockerfile Thu Sep 19 14:14:20 2019
@@ -0,0 +1,20 @@
+FROM python:2.7-alpine
+
+RUN apk update \
+ && apk add --no-cache --virtual .build-deps git g++ postgresql-dev yaml-dev \
+ && apk add --no-cache libpq \
+ && git clone https://git.llvm.org/git/lnt /var/src/lnt \
+ && python /var/src/lnt/setup.py install --server \
+ && rm -rf /var/src \
+ && apk --purge del .build-deps \
+ && mkdir /var/log/lnt
+
+COPY docker-entrypoint.sh wait_db /usr/local/bin/
+
+VOLUME /var/log
+
+EXPOSE 8000
+
+ENV DB_ENGINE= DB_HOST= DB_USER= DB_PWD= DB_BASE=
+
+ENTRYPOINT docker-entrypoint.sh
Added: lnt/trunk/docker/docker-compose.yml
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/docker/docker-compose.yml?rev=372354&view=auto
==============================================================================
--- lnt/trunk/docker/docker-compose.yml (added)
+++ lnt/trunk/docker/docker-compose.yml Thu Sep 19 14:14:20 2019
@@ -0,0 +1,27 @@
+version: '3'
+
+services:
+ lnt:
+ build:
+ context: .
+ container_name: lnt
+ image: lnt
+ environment:
+ - DB_ENGINE=postgres
+ - DB_HOST=lnt-postgres
+ - DB_PWD
+ depends_on:
+ - db
+ deploy:
+ restart_policy:
+ condition: on-failure
+ ports:
+ - "8000:8000"
+
+ db:
+ container_name: lnt-postgres
+ image: postgres:alpine
+ environment:
+ - POSTGRES_PASSWORD=${DB_PWD}
+ - POSTGRES_USER=${DB_USER}
+ - POSTGRES_DB=${DB_BASE}
Added: lnt/trunk/docker/docker-entrypoint.sh
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/docker/docker-entrypoint.sh?rev=372354&view=auto
==============================================================================
--- lnt/trunk/docker/docker-entrypoint.sh (added)
+++ lnt/trunk/docker/docker-entrypoint.sh Thu Sep 19 14:14:20 2019
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+DB_PATH=${DB_ENGINE:-postgresql}://${DB_USER:-lntuser}:${DB_PWD:?}@${DB_HOST:?}
+DB_BASE=${DB_BASE:-lnt}
+
+if [ ! -r /etc/lnt.cfg ]; then
+ DB_BASE_PATH="${DB_PATH}/${DB_BASE}" wait_db
+ lnt create /var/lib/lnt \
+ --config /etc/lnt.cfg \
+ --wsgi lnt_wsgi.py \
+ --tmp-dir /tmp/lnt \
+ --db-dir "${DB_PATH}" \
+ --default-db "${DB_BASE}"
+fi
+
+cd /var/lib/lnt
+exec gunicorn lnt_wsgi:application \
+ --bind 0.0.0.0:8000 \
+ --workers 8 \
+ --timeout 300 \
+ --name lnt_server \
+ --log-file /var/log/lnt/lnt.log \
+ --access-logfile /var/log/lnt/gunicorn_access.log \
+ --max-requests 250000 "$@"
Propchange: lnt/trunk/docker/docker-entrypoint.sh
------------------------------------------------------------------------------
svn:executable = *
Added: lnt/trunk/docker/wait_db
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/docker/wait_db?rev=372354&view=auto
==============================================================================
--- lnt/trunk/docker/wait_db (added)
+++ lnt/trunk/docker/wait_db Thu Sep 19 14:14:20 2019
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+import os
+from sqlalchemy import create_engine
+
+db_base_path = os.environ['DB_BASE_PATH']
+
+engine = create_engine(db_base_path)
+started = False
+
+while not started:
+ try:
+ engine.execute("SELECT 1")
+ started = True
+ except Exception as inst:
+ pass
Propchange: lnt/trunk/docker/wait_db
------------------------------------------------------------------------------
svn:executable = *
More information about the llvm-commits
mailing list