Skip to content
Permalink
Browse files

refactor: update Dockerfile and CI builds

  • Loading branch information...
wei authored and import-yuefeng committed Feb 27, 2019
1 parent 565157b commit 107d971c9239d0dee91810919420cec5483afb32
Showing with 88 additions and 153 deletions.
  1. +5 −0 .dockerignore
  2. +15 −20 .travis.yml
  3. +22 −14 Dockerfile
  4. +4 −1 README.md
  5. +11 −21 docker-compose.yml
  6. +25 −93 init.sh
  7. +6 −4 inspire.py
@@ -0,0 +1,5 @@
*
.*
!*.py
!api/
!requirement.txt
@@ -1,29 +1,24 @@
language: minimal
sudo: required

language: python

python:
- "3.6"

before_install:
- sudo apt-get update -qq
- sudo apt-get install sshpass -qq -y

services:
- docker

env:
- IMAGE_NAME=instantbox/instantbox

script:
- docker build -t="instantbox/instantbox:pre_build" -f ./Dockerfile .
- docker run -d -P --name="inspire" instantbox/instantbox:pre_build
- docker rm -f inspire || true

notifications:
email: true
- docker pull "$IMAGE_NAME" || true
- docker build --cache-from "$IMAGE_NAME"
--build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
--build-arg VCS_REF="$TRAVIS_COMMIT"
-t "$IMAGE_NAME:build" -f ./Dockerfile .
- docker run -d -P --name temp $IMAGE_NAME:build
- docker rm -f temp || true

after_success:
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
docker tag instantbox/instantbox:pre_build instantbox/instantbox;
docker push instantbox/instantbox;
fi

docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD_SECURE";
docker tag "$IMAGE_NAME:build" "$IMAGE_NAME";
docker push "$IMAGE_NAME";
fi
@@ -1,23 +1,31 @@
FROM ubuntu:16.04
MAINTAINER Cat.1 docker@gansi.me
FROM python:3-alpine AS builder

RUN apt-get update -qq && apt-get -y install python3-pip python3 python-dev\
build-essential libssl-dev libffi-dev python3-dev libxml2-dev libxslt1-dev \
zlib1g-dev locales libltdl7 lsof curl
WORKDIR /usr/src/app

COPY requirement.txt ./
RUN pip3 install -q --no-cache-dir -r requirement.txt -t ./ -i https://pypi.tuna.tsinghua.edu.cn/simple
COPY . .
ADD https://raw.githubusercontent.com/instantbox/instantbox-images/master/manifest.json .

RUN locale-gen zh_CN.UTF-8 && rm -rf /var/lib/apt/lists/* && apt-get clean

ENV LC_ALL=zh_CN.UTF-8
ENV PYTHONIOENCODING=utf-8
FROM gcr.io/distroless/python3

RUN mkdir -p /superinspire/ && cd /superinspire
WORKDIR /superinspire
LABEL \
org.label-schema.schema-version="1.0" \
org.label-schema.name="instantbox" \
org.label-schema.vcs-url="https://github.com/instantbox/instantbox" \
maintainer="Instantbox Team <team@instantbox.org>"

ADD requirement.txt /superinspire/
RUN pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple -r /superinspire/requirement.txt
ENV SERVERURL ""

WORKDIR /app
COPY --from=builder /usr/src/app/ .

ADD ./ /superinspire/
EXPOSE 65501
CMD ["inspire.py"]

CMD python3 ./inspire.py
ARG BUILD_DATE
ARG VCS_REF
LABEL \
org.label-schema.build-date=$BUILD_DATE \
org.label-schema.vcs-ref=$VCS_REF
@@ -71,7 +71,10 @@ If you think the experience provided by the official server is too slow, welcome

1. Linux system with docker, Ubuntu:16.04 is recommended

![](./demo/demo.png)
```bash
mkdir instantbox && cd $_
bash <(curl -sSL https://raw.githubusercontent.com/instantbox/instantbox/master/init.sh)"
```
Now you can use the local instantbox! 
By default, please visit localhost:8888 to test.
@@ -1,34 +1,24 @@

version: '3'

services:

inspire:
image: catone/inspire:server
container_name: inspire_flask

server:
image: instantbox/instantbox:latest
container_name: instantbox_server
links:
- redis

volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: python3 ./inspire.py

environment:
- SERVERURL=

redis:
image: redis:latest
container_name: inspire_redis
container_name: instantbox_redis


nginx:
image: catone/inspire:nginx
frontend:
image: instantbox/instantbox-frontend:latest
container_name: instantbox_frontend
links:
- inspire
- server
ports:
- 9010:80
- 8888:81
volumes:
- /var/build:/var/build


container_name: inspire_nginx
- 8888:80
118 init.sh
@@ -1,103 +1,35 @@
# init.sh
#!/bin/sh
#
# Install script for instantbox
# Home Page: https://github.com/instantbox/instantbox
#
# Usage:
# mkdir instantbox && cd $_
# bash <(curl -sSL https://raw.githubusercontent.com/instantbox/instantbox/master/init.sh)"
# docker-compose up -d
#

check_cmd() {
which $1 > /dev/null 2>&1
command -v "$1" >/dev/null 2>&1
}

pretty_name=""
UPDATE=""
INSTALL=""
REMOVE=""
show_distribution() {
echo "Welcome to instantbox, please wait..."
echo ""


if [ -f /etc/os-release ];
then
. /etc/os-release
pretty_name="$PRETTY_NAME"

LSB_ID="$(echo "$ID" | tr '[:upper:]' '[:lower:]')"

elif [ -f /etc/redhat-release ];
then
pretty_name=$(cat /etc/redhat-release)
LSB_ID="$(echo "$pretty_name" | tr '[:upper:]' '[:lower:]')"
echo "$LSB_ID" | grep centos > /dev/null && LSB_ID=centos
fi

LSB_ID=$(echo "$LSB_ID" | tr '[:upper:]' '[:lower:]')

echo "Platform: $pretty_name"
}


detect_pkg_tool() {

check_cmd apt && {
UPDATE="apt update -q"
INSTALL="apt install -y"
REMOVE="apt remove -y"
return 0
}

check_cmd apt-get && {
UPDATE="apt-get update -q"
INSTALL="apt-get install -y"
REMOVE="apt-get remove -y"
return 0
}

check_cmd yum && {
UPDATE="yum update -yq"
INSTALL="yum install -y"
REMOVE="yum "
PKG_LIBEV="libev-devel"
PKG_SSL="openssl-devel"
return 0
}

check_cmd pacman && {
UPDATE="pacman -Sy --noprogressbar"
INSTALL="pacman -S --noconfirm --noprogressbar"
REMOVE="pacman -R --noconfirm --noprogressbar"
PKG_LIBEV="libev"
PKG_SSL="openssl"
return 0
}

return 1
}

clone_html(){
git clone https://github.com/super-inspire/super-inspire-frontend.git /var/super-inspire-frontend
mv /var/super-inspire-frontend/build /var/build
rm -rf /var/super-inspire-frontend
}



show_distribution
detect_pkg_tool

if [[ detect_pkg_tool == 1 ]]; then
echo 'not support platform'
exit 1
if check_cmd docker-compose; then
curl -sSL https://raw.githubusercontent.com/docker/compose/master/script/run/run.sh > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose || exit 1
fi

check_cmd git || {
$UPDATE && $INSTALL git
}

check_cmd wget || {
$UPDATE && $INSTALL wget
}

clone_html
curl -sSLO https://raw.githubusercontent.com/instantbox/instantbox/master/docker-compose.yml

check_cmd docker-compose || {
wget https://github.com/docker/compose/releases/download/1.23.2/docker-compose-Linux-x86_64
mv docker-compose-Linux-x86_64 docker-compose && chmod +x docker-compose
mv docker-compose /usr/bin
}
echo "Enter your IP (optional): "
read IP
echo "Choose a port (default: 8888): "
read PORT

[ -z "$IP" ] || sed -i -e "s/SERVERURL=$/SERVERURL=$IP/" docker-compose.yml
[ -z "$PORT" ] || sed -i -e "s/8888:80/$PORT:80/" docker-compose.yml

echo "You're all set! "
echo "Run 'docker-compose up -d' then go to http://${IP:-localhost}:${PORT:-8888} on your browser."
@@ -1,3 +1,5 @@
#!/bin/python

import re
import os
import sys
@@ -7,10 +9,10 @@
import string
import subprocess
from flask_cors import CORS
from API.redisCli import ConnectRedis
from API.rmContainer import RmContainer
from api.redisCli import ConnectRedis
from api.rmContainer import RmContainer
from flask import render_template,redirect
from API.createContainer import CreateContainer
from api.createContainer import CreateContainer
from flask import Flask,request,Response,jsonify


@@ -24,7 +26,7 @@
rm_container_client = RmContainer()


SERVERURL = os.popen('curl ip.sb').readlines()[0].split('\n')[0]
SERVERURL = os.environ.get('SERVERURL')


OS_SWITCH = {

0 comments on commit 107d971

Please sign in to comment.
You can’t perform that action at this time.