mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
Merge pull request #2127 from Zexi/feature/build-docker-image
添加各个组件制作成 docker 镜像的 Dockerfile
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Executable
+39
@@ -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
|
||||
Reference in New Issue
Block a user