Merge pull request #2127 from Zexi/feature/build-docker-image

添加各个组件制作成 docker 镜像的 Dockerfile
This commit is contained in:
yunion-ci-robot
2019-08-09 20:17:59 +08:00
committed by GitHub
16 changed files with 167 additions and 14 deletions
+14
View File
@@ -0,0 +1,14 @@
FROM alpine:3.8
MAINTAINER "Zexi Li <lizexi@yunionyun.com>"
ENV TZ Asia/Shanghai
RUN mkdir -p /opt/yunion/bin
RUN apk update && \
apk add --no-cache ipmitool ethtool && \
rm -rf /var/cache/apk/*
ADD ./_output/bin/baremetal-agent /opt/yunion/bin/baremetal-agent
+13
View File
@@ -0,0 +1,13 @@
FROM alpine:3.8
MAINTAINER "Zexi Li <lizexi@yunionyun.com>"
ENV TZ Asia/Shanghai
RUN apk add bash bash-completion
ENV PATH="/opt/yunion/bin:${PATH}"
RUN mkdir -p /opt/yunion/bin
ADD ./_output/bin/climc /opt/yunion/bin/climc
+16
View File
@@ -0,0 +1,16 @@
FROM centos:centos7
MAINTAINER "Zexi Li <lizexi@yunionyun.com>"
ENV TZ Asia/Shanghai
RUN yum install -y libaio
RUN rpm --import https://download.ceph.com/keys/release.asc
RUN yum install -y https://download.ceph.com/rpm-luminous/el7/noarch/ceph-release-1-1.el7.noarch.rpm
RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN yum install -y libcephfs-devel librbd-devel librados-devel
RUN yum install -y https://iso.yunion.cn/yumrepo-2.10/rpms/packages/yunion-qemu-2.12.1-2.12.1-1.el7.centos.x86_64.rpm https://iso.yunion.cn/yumrepo-2.10/rpms/packages/spice-0.13.3-1.el7.centos.x86_64.rpm
RUN mkdir -p /opt/yunion/bin
ADD ./_output/bin/glance /opt/yunion/bin/glance
ADD ./_output/bin/torrent /opt/yunion/bin/torrent
+9
View File
@@ -0,0 +1,9 @@
FROM alpine:3.8
MAINTAINER "Zexi Li <lizexi@yunionyun.com>"
ENV TZ Asia/Shanghai
RUN mkdir -p /opt/yunion/bin
ADD ./_output/bin/keystone /opt/yunion/bin/keystone
+10
View File
@@ -0,0 +1,10 @@
FROM alpine:3.8
MAINTAINER "Zexi Li <lizexi@yunionyun.com>"
ENV TZ Asia/Shanghai
RUN mkdir -p /opt/yunion/bin
ADD ./_output/bin/logger /opt/yunion/bin/logger
+9
View File
@@ -0,0 +1,9 @@
FROM alpine:3.8
MAINTAINER "Zexi Li <lizexi@yunionyun.com>"
ENV TZ Asia/Shanghai
RUN mkdir -p /opt/yunion/bin
ADD ./_output/bin/region /opt/yunion/bin/region
+9
View File
@@ -0,0 +1,9 @@
FROM alpine:3.8
MAINTAINER "Zexi Li <lizexi@yunionyun.com>"
ENV TZ Asia/Shanghai
RUN mkdir -p /opt/yunion/bin
ADD ./_output/bin/region-dns /opt/yunion/bin/region-dns
+9
View File
@@ -0,0 +1,9 @@
FROM alpine:3.8
MAINTAINER "Zexi Li <lizexi@yunionyun.com>"
ENV TZ Asia/Shanghai
RUN mkdir -p /opt/yunion/bin
ADD ./_output/bin/scheduler /opt/yunion/bin/scheduler
+11
View File
@@ -0,0 +1,11 @@
FROM alpine:3.8
MAINTAINER "Zexi Li <lizexi@yunionyun.com>"
ENV TZ Asia/Shanghai
RUN mkdir -p /opt/yunion/bin
RUN apk add --no-cache sshpass ipmitool openssh-client
ADD ./_output/bin/webconsole /opt/yunion/bin/webconsole
+10
View File
@@ -0,0 +1,10 @@
FROM alpine:3.8
MAINTAINER "Zexi Li <lizexi@yunionyun.com>"
ENV TZ Asia/Shanghai
RUN mkdir -p /opt/yunion/bin
ADD ./_output/bin/yunionconf /opt/yunion/bin/yunionconf
+4
View File
@@ -595,6 +595,10 @@ func (manager *SUserManager) traceLoginEvent(ctx context.Context, token mcclient
usr.LastLoginSource = authCtx.Source
return nil
})
// ignore operator auth source
if authCtx.Source == mcclient.AuthSourceOperator {
return
}
db.OpsLog.LogEvent(usr, "auth", &s, token)
logclient.AddActionLogWithContext(ctx, usr, logclient.ACT_AUTHENTICATE, &s, token, true)
}
+4 -9
View File
@@ -48,18 +48,13 @@ func StartService() {
log.Infof("Auth complete!!")
})
cloudcommon.InitDB(dbOpts)
app := app_common.InitApp(baseOpts, true)
initHandlers(app)
db.EnsureAppInitSyncDB(app, dbOpts, nil)
defer cloudcommon.CloseDB()
models.StartNotifyToWebsocketWorker()
app := app_common.InitApp(baseOpts, true)
cloudcommon.AppDBInit(app)
initHandlers(app)
if !db.CheckSync(opts.AutoSyncTable) {
log.Fatalf("database schema not in sync!")
}
app_common.ServeForever(app, baseOpts)
}
+5 -4
View File
@@ -15,10 +15,11 @@
package mcclient
const (
AuthSourceWeb = "web"
AuthSourceAPI = "api"
AuthSourceCli = "cli"
AuthSourceSrv = "srv"
AuthSourceWeb = "web"
AuthSourceAPI = "api"
AuthSourceCli = "cli"
AuthSourceSrv = "srv"
AuthSourceOperator = "operator"
)
type SAuthContext struct {
+4
View File
@@ -217,6 +217,10 @@ func (this *Client) AuthenticateWeb(uname, passwd, domainName, tenantName, tenan
return this.authenticateWithContext(uname, passwd, domainName, tenantName, tenantDomain, aCtx)
}
func (this *Client) AuthenticateOperator(uname, passwd, domainName, tenantName, tenantDomain string) (TokenCredential, error) {
return this.AuthenticateWithSource(uname, passwd, domainName, tenantName, tenantDomain, AuthSourceOperator)
}
func (this *Client) AuthenticateWithSource(uname, passwd, domainName, tenantName, tenantDomain string, source string) (TokenCredential, error) {
aCtx := SAuthContext{
Source: source,
+1 -1
View File
@@ -52,7 +52,7 @@ func StartService() {
log.Fatalf("invalid --api-server %s", opts.ApiServer)
}
for _, binPath := range []string{opts.KubectlPath, opts.IpmitoolPath, opts.SshToolPath, opts.SshpassToolPath} {
for _, binPath := range []string{opts.IpmitoolPath, opts.SshToolPath, opts.SshpassToolPath} {
ensureBinExists(binPath)
}
+39
View File
@@ -0,0 +1,39 @@
#!/bin/bash
set -o errexit
set -o pipefail
pushd $(dirname $(readlink -f "$BASH_SOURCE")) > /dev/null
CUR_DIR=$(pwd)
SRC_DIR=$(cd .. && pwd)
popd > /dev/null
DOCKER_DIR="$SRC_DIR/build/docker"
REGISTRY=${REGISTRY:-docker.io/yunion}
TAG=${TAG:-latest}
build_bin() {
CGO_ENABLED=0 make cmd/$1
}
build_image() {
local tag=$1
local file=$2
local path=$3
docker build -t "$tag" -f "$2" "$3"
}
push_image() {
local tag=$1
docker push "$tag"
}
COMPONENTS=$@
for compent in $COMPONENTS; do
build_bin $compent
img_name="$REGISTRY/$compent:$TAG"
build_image $img_name $DOCKER_DIR/Dockerfile.$compent $SRC_DIR
push_image "$img_name"
done