Initial Proposal for Docker (#16)

This commit is contained in:
Sukchan Lee 2018-02-20 19:36:34 +09:00
parent 38cccb8a85
commit 9a86d4cb7c
12 changed files with 235 additions and 47 deletions

View File

@ -1,35 +1,44 @@
WebUI & MongoDB
Docker running example
===========================================
* docker-compose up
* Create default-image with ubuntu-xenial
$ docker-compose up -d
Ubuntu Package
===========================================
* Remove dangling container if the status is exited
$ docker rm $(docker ps -qa --no-trunc --filter "status=exited")
* cd sample
* docker build -t nextepc .
* docker run --net=host --hostname nextepc -ti --name nextepc --privileged --cap-add=SYS_ADMIN -e "container=docker" -v /sys/fs/cgroup:/sys/fs/cgroup -v $PWD:/mnt nextepc /sbin/init
* docker exec -it /bin/bash
* sudo apt-get install curl sudo
* curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
* curl -sL http://nextepc.org/static/webui/install | sudo -E bash -
* Development
$ docker-compose run --rm dev
* Runtime
$ docker-compose -f docker-compose.yml -f docker-compose.run.yml \
run --rm run
* Test
$ docker-compose -f docker-compose.yml -f docker-compose.test.yml \
run --rm test
* Test with ubuntu-artful
$ TAG=artful docker-compose up -d
$ TAG=artful docker-compose -f docker-compose.yml -f docker-compose.test.yml \
run --rm test
* Development with centos:latest(TODO)
$ DIST=centos docker-compose up -d
$ DIST=centos docker-compose run --rm dev
* Runtime with debian-jessie(TODO)
$ DIST=debian TAG=jessie docker-compose up -d
$ DIST=debian TAG=jessie docker-compose \
-f docker-compose.yml -f docker-compose.run.yml run --rm run
* All Test with All Environment(TODO)
$ ./check.sh
For Debian Package Release
===========================================
* Ubuntu Docker Setup
$ docker run -p 4000:3000 --hostname build -ti --name build --privileged --cap-add=SYS_ADMIN -e "container=docker" -v /sys/fs/cgroup:/sys/fs/cgroup -v $PWD:/mnt ubuntu /sbin/init
$ docker exec -it ubuntu /bin/login
* Access Source Repository
$ sudo apt-get install sudo vim dpkg-dev git
$ git clone https://github.com/acetcom/nextepc
$ git checkout new_branch
* Check Pakcage
$ dpkg-buildpackage
$ sudo apt-get install ....
$ dpkg-buildpackage
* Run Docker
$ docker-compose run --rm dev
* Setup Debian Environment
export DEBFULLNAME='Sukchan Lee'
@ -42,12 +51,11 @@ export DEBEMAIL='acetcom@gmail.com'
$ gpg --import public.asc
* Update debian/changelog
$ sudo apt-get install devscripts
$ dch -i
* Test OBS
* Generate Package
$ dpkg-buildpackage
$ debuild -S
- Upload *.dsc and *.tar.gz to https://build.opensuse.org/package/show/home:acetcom/nextepc
* Upload LaunchPad
$ dput ppa:acetcom/nextepc *.source.changes

View File

@ -0,0 +1,15 @@
ARG dist=ubuntu
ARG tag=latest
ARG username=acetcom
FROM ${username}/${dist}-${tag}-base
MAINTAINER Sukchan Lee <acetcom@gmail.com>
WORKDIR /tmp
RUN git clone https://github.com/acetcom/nextepc
RUN cd nextepc && \
autoreconf -iv && \
./configure && \
make -j `nproc` && \
make install

9
support/docker/check.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
docker-compose up -d
docker-compose -f docker-compose.yml -f docker-compose.test.yml run --rm test
docker rm $(docker ps -qa --no-trunc --filter "status=exited")
TAG=artful docker-compose up -d
TAG=artful docker-compose -f docker-compose.yml -f docker-compose.test.yml run --rm test
docker rm $(docker ps -qa --no-trunc --filter "status=exited")

View File

@ -0,0 +1,20 @@
version: '3'
services:
run:
# network_mode: "host"
image: ${USER}/${DIST-ubuntu}-${TAG-latest}-build
depends_on:
- mongodb
- build
environment:
DB_URI: mongodb://mongodb/nextepc
cap_add:
- NET_ADMIN
devices:
- "/dev/net/tun:/dev/net/tun"
sysctls:
- net.ipv6.conf.all.disable_ipv6=0
- net.ipv6.conf.all.forwarding=1
hostname: nextepc-run
command: /bin/bash -c "/etc/init.d/networking start; sed 's|localhost|mongodb|' /usr/local/etc/nextepc/nextepc.conf > /tmp/nextepc.conf; mv -f /tmp/nextepc.conf /usr/local/etc/nextepc/; /usr/local/bin/nextepc-epcd"

View File

@ -0,0 +1,19 @@
version: '3'
services:
test:
image: ${USER}/${DIST-ubuntu}-${TAG-latest}-build
depends_on:
- mongodb
- build
environment:
DB_URI: mongodb://mongodb/nextepc
cap_add:
- NET_ADMIN
devices:
- "/dev/net/tun:/dev/net/tun"
sysctls:
- net.ipv6.conf.all.disable_ipv6=0
- net.ipv6.conf.all.forwarding=1
hostname: nextepc-test
command: /bin/bash -c "/etc/init.d/networking start; sed 's|localhost|mongodb|' /usr/local/etc/nextepc/nextepc.conf > /tmp/nextepc.conf; mv -f /tmp/nextepc.conf /usr/local/etc/nextepc/; cd nextepc; ./test/testepc"

View File

@ -1,8 +1,20 @@
version: '3'
services:
mongodb:
image: mongo
container_name: nextepc-mongodb
ports:
- "27017:27017"
volumes:
- mongodb:/data/db
webui:
build: ./webui
build: webui
image: ${USER}/nextepc-webui
container_name: nextepc-webui
depends_on:
- mongodb
ports:
- "3000:3000"
depends_on:
@ -10,12 +22,50 @@ services:
environment:
DB_URI: mongodb://mongodb/nextepc
mongodb:
image: mongo
ports:
- "27017:27017"
base:
build:
context: ./${DIST-ubuntu}/base
args:
tag: ${TAG-latest}
image: ${USER}/${DIST-ubuntu}-${TAG-latest}-base
command: /bin/bash -c "echo 'base' services"
build:
build:
context: ./build
args:
dist: ${DIST-ubuntu}
tag: ${TAG-latest}
username: ${USER}
image: ${USER}/${DIST-ubuntu}-${TAG-latest}-build
depends_on:
- base
command: /bin/bash -c "echo 'build' services"
dev:
build:
context: ./${DIST-ubuntu}/dev
args:
tag: ${TAG-latest}
username: ${USER}
image: ${USER}/${DIST-ubuntu}-${TAG-latest}-dev
depends_on:
- mongodb
- base
environment:
DB_URI: mongodb://mongodb/nextepc
cap_add:
- NET_ADMIN
devices:
- "/dev/net/tun:/dev/net/tun"
sysctls:
- net.ipv6.conf.all.disable_ipv6=0
- net.ipv6.conf.all.forwarding=1
volumes:
- db-data:/data/db
- home:/home/${USER}
hostname: nextepc-dev
command: /bin/bash -c "chmod 666 /dev/net/tun; /etc/init.d/networking start; su acetcom"
volumes:
db-data:
mongodb: {}
home: {}

View File

@ -0,0 +1,10 @@
ARG tag=latest
FROM ubuntu:${tag}
RUN apt-get update && \
apt-get -y install software-properties-common && \
add-apt-repository ppa:acetcom/nextepc && \
apt-get update && \
apt-get install -y nextepc
WORKDIR /root

View File

@ -1,9 +0,0 @@
FROM ubuntu:16.04
RUN \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv F26B05AF && \
echo "deb http://ppa.launchpad.net/acetcom/nextepc/ubuntu xenial main" > /etc/apt/sources.list.d/nextepc.list && \
apt-get update && \
apt-get install -y nextepc
WORKDIR /root

View File

@ -0,0 +1,33 @@
ARG tag=latest
FROM ubuntu:${tag}
MAINTAINER Sukchan Lee <acetcom@gmail.com>
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
autoconf \
libtool \
gcc \
flex \
bison \
git \
debhelper \
devscripts \
dh-autoreconf \
dh-systemd \
libsctp-dev \
libgnutls28-dev \
libgcrypt-dev \
libssl-dev \
libmongoc-dev \
libbson-dev \
libyaml-dev \
build-essential \
ca-certificates \
netbase \
ifupdown \
pkg-config && \
apt-get clean
COPY nextepc /etc/network/interfaces.d/

View File

@ -0,0 +1,9 @@
auto pgwtun
iface pgwtun inet static
address 45.45.0.1
netmask 255.255.0.0
pre-up ip tuntap add name pgwtun mode tun
post-down ip tuntap del name pgwtun mode tun
iface pgwtun inet6 static
address cafe::1
netmask 64

View File

@ -0,0 +1,23 @@
ARG tag=latest
ARG username=acetcom
FROM ${username}/ubuntu-${tag}-base
MAINTAINER Sukchan Lee <acetcom@gmail.com>
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
cscope \
vim \
sudo \
iproute2 \
iputils-ping \
net-tools && \
apt-get clean
ARG username=acetcom
RUN useradd -m --uid=1000 ${username} && \
echo "${username} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${username} && \
chmod 0440 /etc/sudoers.d/${username}
WORKDIR /home/${username}

View File

@ -1,9 +1,10 @@
FROM node:carbon
ENV PACKAGE nextepc
ENV VERSION 0.3.3
MAINTAINER Sukchan Lee <acetcom@gmail.com>
ARG PACKAGE=nextepc
ARG VERSION=0.3.3
RUN apt-get -y install curl
RUN set -e; \
cd /usr/src; \
rm -rf ./$PACKAGE; \