mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
Docker based environment setup
Replicate production setup in Docker containers [YOCTO #7575] Signed-off-by: Alex Franco <alejandro.franco@linux.intel.com> Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
parent
d83844736f
commit
e6233b61cd
34
Dockerfile
Normal file
34
Dockerfile
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
FROM buildpack-deps:latest
|
||||||
|
MAINTAINER Michael Halstead <mhalstead@linuxfoundation.org>
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
ENV PYTHONUNBUFFERED 1
|
||||||
|
## Uncomment to set proxy ENVVARS within container
|
||||||
|
#ENV http_proxy http://your.proxy.server:port
|
||||||
|
#ENV https_proxy https://your.proxy.server:port
|
||||||
|
|
||||||
|
RUN apt-get update
|
||||||
|
RUN apt-get install -y --no-install-recommends \
|
||||||
|
python-pip \
|
||||||
|
python-mysqldb \
|
||||||
|
python-dev \
|
||||||
|
python-imaging \
|
||||||
|
netcat-openbsd \
|
||||||
|
vim \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
RUN pip install --upgrade pip
|
||||||
|
RUN pip install gunicorn
|
||||||
|
CMD mkdir /opt/workdir
|
||||||
|
ADD . /opt/layerindex
|
||||||
|
RUN pip install -r /opt/layerindex/requirements.txt
|
||||||
|
ADD settings.py /opt/layerindex/settings.py
|
||||||
|
ADD docker/updatelayers.sh /opt/updatelayers.sh
|
||||||
|
ADD docker/migrate.sh /opt/migrate.sh
|
||||||
|
|
||||||
|
## Uncomment to add a .gitconfig file within container
|
||||||
|
#ADD docker/.gitconfig /root/.gitconfig
|
||||||
|
## Uncomment to add a proxy script within container, if you choose to
|
||||||
|
## do so, you will also have to edit .gitconfig appropriately
|
||||||
|
#ADD docker/git-proxy /opt/bin/git-proxy
|
||||||
|
|
||||||
|
CMD ["/usr/local/bin/gunicorn", "wsgi:application", "--workers=4", "--bind=:5000", "--log-level=debug", "--chdir=/opt/layerindex"]
|
4
Dockerfile.web
Normal file
4
Dockerfile.web
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
FROM nginx:latest
|
||||||
|
MAINTAINER Michael Halstead <mhalstead@linuxfoundation.org>
|
||||||
|
COPY docker/nginx.conf /etc/nginx/nginx.conf
|
||||||
|
COPY layerindex/static /usr/share/nginx/html/static
|
3
README
3
README
|
@ -107,6 +107,9 @@ Setup instructions:
|
||||||
* templates/base.html
|
* templates/base.html
|
||||||
* templates/layerindex/about.html
|
* templates/layerindex/about.html
|
||||||
|
|
||||||
|
7. To use layerindex-web with Docker containers, refer to docker/README
|
||||||
|
keeping in mind you'll need to set up Docker properly as part of the
|
||||||
|
setup process.
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
|
|
11
docker/.gitconfig
Normal file
11
docker/.gitconfig
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# This .gitconfig file resides in /root/ in the "layersapp" container
|
||||||
|
# add any settings you'd like to have in there, such as proxy servers
|
||||||
|
[http]
|
||||||
|
#proxy = http://your.proxy.server:port
|
||||||
|
[https]
|
||||||
|
#proxy = https://your.proxy.server:port
|
||||||
|
[core]
|
||||||
|
# Optional: uncomment this line if you want to use a proxy script
|
||||||
|
#gitproxy = /opt/bin/git-proxy
|
||||||
|
[socks]
|
||||||
|
#proxy = your.socks.proxy:port
|
26
docker/README
Normal file
26
docker/README
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
## This is set up to make a cluster of three containers. First we build two from the root of the repo.
|
||||||
|
docker build -t halstead/layerindex-app .
|
||||||
|
docker build -t halstead/layerindex-web -f Dockerfile.web .
|
||||||
|
|
||||||
|
## Start a database server. We use MariaDB in production.
|
||||||
|
## In order to configure your settings.py file to use this database server, use:
|
||||||
|
## 'ENGINE': 'django.db.backends.mysql',
|
||||||
|
## 'NAME': 'layersdb',
|
||||||
|
## 'USER': 'root',
|
||||||
|
## 'PASSWORD': 'testingpw',
|
||||||
|
## 'HOST': 'layersdb',
|
||||||
|
## 'PORT': '',
|
||||||
|
docker run -d --name layerdb -e MYSQL_ROOT_PASSWORD=testingpw -e MYSQL_DATABASE=layersdb mariadb
|
||||||
|
|
||||||
|
## If you have a copy of the the production data now is the time to insert it.
|
||||||
|
## If not you can skip the next step for a clean install.
|
||||||
|
xzcat ./layerdb.sql.xz | docker run -i --link layerdb:layersdb --rm mariadb sh -c 'exec mysql -hlayersdb -uroot -p"testingpw" layersdb'
|
||||||
|
|
||||||
|
docker run -d --link layerdb:layersdb --name layersapp halstead/layerindex-app
|
||||||
|
docker run -d --link layersapp:layersapp --name layersweb -p 49153:80 halstead/layerindex-web
|
||||||
|
|
||||||
|
## To apply layerindex migration
|
||||||
|
docker run --rm --link layerdb:layersdb halstead/layerindex-app /opt/migrate.sh
|
||||||
|
|
||||||
|
## To update the layer info we can run the job in a temporary container.
|
||||||
|
docker run --rm --link layerdb:layersdb halstead/layerindex-app /opt/updatelayers.sh
|
12
docker/git-proxy
Executable file
12
docker/git-proxy
Executable file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This simple proxy script (for git) resides at /opt/bin in the layersapp
|
||||||
|
# container. If you use it, uncomment the appropriate line in .gitproxy
|
||||||
|
# this method has been tested using a socks proxy
|
||||||
|
PROXY=your.proxy.server
|
||||||
|
PORT=portnumber
|
||||||
|
|
||||||
|
METHOD="-X 5 -x ${PROXY}:${PORT}"
|
||||||
|
|
||||||
|
# BSD netcat is used to connect
|
||||||
|
/bin/nc $METHOD $*
|
2
docker/migrate.sh
Executable file
2
docker/migrate.sh
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/bash
|
||||||
|
python /opt/layerindex/manage.py migrate layerindex
|
47
docker/nginx.conf
Normal file
47
docker/nginx.conf
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
#daemon off; ##Included in CMD
|
||||||
|
error_log /dev/stdout info;
|
||||||
|
worker_processes 1;
|
||||||
|
|
||||||
|
# user nobody nogroup;
|
||||||
|
pid /tmp/nginx.pid;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
accept_mutex off;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
include mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
access_log /dev/stdout combined;
|
||||||
|
sendfile on;
|
||||||
|
|
||||||
|
upstream app_server {
|
||||||
|
# For a TCP configuration:
|
||||||
|
server layersapp:5000 fail_timeout=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80 default;
|
||||||
|
client_max_body_size 4G;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
keepalive_timeout 5;
|
||||||
|
|
||||||
|
# path for static files
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri @proxy_to_app;
|
||||||
|
}
|
||||||
|
|
||||||
|
location @proxy_to_app {
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_redirect off;
|
||||||
|
|
||||||
|
proxy_pass http://app_server;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
9
docker/updatelayers.sh
Executable file
9
docker/updatelayers.sh
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/bash
|
||||||
|
update=/opt/layerindex/layerindex/update.py
|
||||||
|
$update -q -r
|
||||||
|
$update -b jethro -x -r -q
|
||||||
|
$update -b fido -x -r -q
|
||||||
|
$update -b dizzy -x -r -q
|
||||||
|
$update -b daisy -x -r -q
|
||||||
|
$update -b dora -x -r -q
|
||||||
|
$update -b dylan -x -r -q
|
Loading…
Reference in New Issue
Block a user