Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: provide cyclone base images to build images #1407

Merged
merged 1 commit into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ ROOT := github.com/caicloud/cyclone

# Target binaries. You can build multiple binaries for a single project.
TARGETS := server workflow/controller workflow/coordinator cicd/cd toolbox/fstream
IMAGES := server workflow/controller workflow/coordinator resolver/git resolver/svn resolver/image watcher cicd/cd cicd/sonarqube toolbox web
IMAGES := server workflow/controller workflow/coordinator resolver/git resolver/svn resolver/image watcher cicd/cd cicd/sonarqube toolbox
BASE_IMAGES := base/alpine base/openjdk

# Container image prefix and suffix added to targets.
# The final built images are:
Expand All @@ -35,13 +36,18 @@ IMAGES := server workflow/controller workflow/coordinator resolver/git resolver/
IMAGE_PREFIX ?= $(strip cyclone-)
IMAGE_SUFFIX ?= $(strip )

# REGISTRY ?= docker.io/library
# Container registry for target images.
REGISTRY ?= docker.io/library
REGISTRY ?= docker.io/caicloud

# Container registry for base images.
# Container registry for images used to complile, like building golang binaries and building webs, e.g. docker.io/library/golang.
BASE_REGISTRY ?= docker.io/library
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not update this?


# Container registry for cyclone target base images.
CYCLONE_BASE_REGISTRY ?= docker.io/caicloud
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think not need this, can reuse the REGISTRY, as target images and base images will been in the same registry
.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CYCLONE_BASE_REGISTRY does not need updating frequently, it's used as base images in the Dockerfiles, and these Dockerfiles Base images will not be updated frequently.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think not need this, can reuse the REGISTRY, as the target images and base images will been in the same registry.


# Version of the cyclone base images.
CYCLONE_BASE_VERSION ?= v1.0.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prefix CYCLONE_ is not necessary.

Suggested change
CYCLONE_BASE_VERSION ?= v1.0.0
BASE_VERSION ?= v1.0.0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to keep consistent with CYCLONE_BASE_REGISTRY.


# Example scene
SCENE ?= cicd

Expand All @@ -52,6 +58,7 @@ ARCH ?= amd64
ifeq ($(ARCH),arm64)
DOCKERFILE ?= Dockerfile.arm64
REGISTRY ?= cargo.dev.caicloud.xyz/arm64v8
CYCLONE_BASE_VERSION := $(CYCLONE_BASE_VERSION)-arm64v8
else
DOCKERFILE ?= Dockerfile
REGISTRY ?= cargo.dev.caicloud.xyz/release
Expand Down Expand Up @@ -184,6 +191,13 @@ container-local: build-local
-f $(BUILD_DIR)/$${image}/$(DOCKERFILE) .; \
done

container-base:
@for image in $(BASE_IMAGES); do \
imageName=$(IMAGE_PREFIX)$${image/\//-}$(IMAGE_SUFFIX); \
docker build -t ${CYCLONE_BASE_REGISTRY}/$${imageName}:${CYCLONE_BASE_VERSION} \
-f $(BUILD_DIR)/$${image}/$(DOCKERFILE) .; \
done

push:
@for image in $(IMAGES); do \
imageName=$(IMAGE_PREFIX)$${image/\//-}$(IMAGE_SUFFIX); \
Expand Down
15 changes: 15 additions & 0 deletions build/base/alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM alpine:3.8
LABEL maintainer="[email protected]"

RUN apk update && \
apk add --no-cache ca-certificates bash coreutils git subversion curl jq

ENV DOCKER_VERSION 18.06.0
RUN curl -O https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}-ce.tgz && \
tar -xzf docker-${DOCKER_VERSION}-ce.tgz && \
mv docker/docker /usr/local/bin/docker && \
rm -rf ./docker docker-${DOCKER_VERSION}-ce.tgz

RUN apk add tzdata && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone
17 changes: 17 additions & 0 deletions build/base/alpine/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM arm64v8/alpine:3.8
LABEL maintainer="[email protected]"

RUN apk update && \
apk add --no-cache ca-certificates bash coreutils git subversion curl jq

ENV DOCKER_VERSION=18.06.0
RUN curl -O https://download.docker.com/linux/static/stable/aarch64/docker-${DOCKER_VERSION}-ce.tgz && \
tar -xzf docker-${DOCKER_VERSION}-ce.tgz && \
mv docker/docker /usr/local/bin/docker && \
rm -rf ./docker docker-${DOCKER_VERSION}-ce.tgz

RUN apk add --no-cache tzdata && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone


40 changes: 40 additions & 0 deletions build/base/openjdk/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM library/openjdk:8-alpine3.8

RUN apk add --no-cache curl grep sed unzip bash nodejs nodejs-npm

# Set timezone to CST
ENV TZ=America/Chicago
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

WORKDIR /usr/src

RUN curl --insecure -o ./sonarscanner.zip -L https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.3.0.1492-linux.zip && \
unzip sonarscanner.zip && \
rm sonarscanner.zip && \
mv sonar-scanner-3.3.0.1492-linux /usr/lib/sonar-scanner && \
ln -s /usr/lib/sonar-scanner/bin/sonar-scanner /usr/local/bin/sonar-scanner

ENV SONAR_RUNNER_HOME=/usr/lib/sonar-scanner

COPY build/base/openjdk/sonar-runner.properties /usr/lib/sonar-scanner/conf/sonar-scanner.properties

# ensure Sonar uses the provided Java for musl instead of a borked glibc one
RUN sed -i 's/use_embedded_jre=true/use_embedded_jre=false/g' /usr/lib/sonar-scanner/bin/sonar-scanner

# Separating ENTRYPOINT and CMD operations allows for core execution variables to
# be easily overridden by passing them in as part of the `docker run` command.
# This allows the default /usr/src base dir to be overridden by users as-needed.

# ENTRYPOINT ["sonar-scanner"]
CMD ["-Dsonar.projectBaseDir=/usr/src"]

# ==================== #
# Contents above copied from https://github.com/newtmitch/docker-sonar-scanner/blob/master/Dockerfile.sonarscanner-3.3.0-alpine
# ==================== #

# FROM newtmitch/sonar-scanner:3.3.0-alpine

LABEL maintainer="[email protected]"

RUN apk update && \
apk add --no-cache ca-certificates bash coreutils curl jq
43 changes: 43 additions & 0 deletions build/base/openjdk/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM arm64v8/openjdk:8-alpine3.8

RUN apk add --no-cache curl grep sed unzip bash nodejs nodejs-npm

# Set timezone to CST
ENV TZ=America/Chicago
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

WORKDIR /usr/src

RUN curl --insecure -o ./sonarscanner.zip -L https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.3.0.1492-linux.zip && \
unzip sonarscanner.zip && \
rm sonarscanner.zip && \
mv sonar-scanner-3.3.0.1492-linux /usr/lib/sonar-scanner && \
ln -s /usr/lib/sonar-scanner/bin/sonar-scanner /usr/local/bin/sonar-scanner

ENV SONAR_RUNNER_HOME=/usr/lib/sonar-scanner

COPY build/base/openjdk/sonar-runner.properties /usr/lib/sonar-scanner/conf/sonar-scanner.properties

# ensure Sonar uses the provided Java for musl instead of a borked glibc one
RUN sed -i 's/use_embedded_jre=true/use_embedded_jre=false/g' /usr/lib/sonar-scanner/bin/sonar-scanner

# Separating ENTRYPOINT and CMD operations allows for core execution variables to
# be easily overridden by passing them in as part of the `docker run` command.
# This allows the default /usr/src base dir to be overridden by users as-needed.

# ENTRYPOINT ["sonar-scanner"]
CMD ["-Dsonar.projectBaseDir=/usr/src"]

# ==================== #
# Contents above copied from https://github.com/newtmitch/docker-sonar-scanner/blob/master/Dockerfile.sonarscanner-3.3.0-alpine,
# in order to build an arm64 supported image of newtmitch/sonar-scanner:3.3.0-alpine
# ==================== #

# FROM newtmitch/sonar-scanner:3.3.0-alpine

LABEL maintainer="[email protected]"

RUN apk update && \
apk add --no-cache ca-certificates bash coreutils curl jq


2 changes: 1 addition & 1 deletion build/cicd/cd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.8
FROM caicloud/cyclone-base-alpine:v1.0.0

LABEL maintainer="[email protected]"

Expand Down
2 changes: 1 addition & 1 deletion build/cicd/cd/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM arm64v8/alpine:3.8
FROM caicloud/cyclone-base-alpine:v1.0.0-arm64v8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arm64v8 是不是不要放在 tag 里区分,我感觉放在 project 里区分比较好一些

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

打扰了 dockerhub 不支持


LABEL maintainer="[email protected]"

Expand Down
5 changes: 1 addition & 4 deletions build/cicd/sonarqube/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
FROM newtmitch/sonar-scanner:3.3.0-alpine
FROM caicloud/cyclone-base-openjdk:v1.0.0

LABEL maintainer="[email protected]"

ENV WORKDIR /workspace
WORKDIR $WORKDIR

RUN wget -O /bin/jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && \
chmod +x /bin/jq

COPY ./build/cicd/sonarqube/entrypoint.sh /

ENTRYPOINT ["/entrypoint.sh"]
39 changes: 1 addition & 38 deletions build/cicd/sonarqube/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,47 +1,10 @@
FROM arm64v8/openjdk:8-alpine3.8

RUN apk add --no-cache curl grep sed unzip bash nodejs nodejs-npm

# Set timezone to CST
ENV TZ=America/Chicago
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

WORKDIR /usr/src

RUN curl --insecure -o ./sonarscanner.zip -L https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.3.0.1492-linux.zip && \
unzip sonarscanner.zip && \
rm sonarscanner.zip && \
mv sonar-scanner-3.3.0.1492-linux /usr/lib/sonar-scanner && \
ln -s /usr/lib/sonar-scanner/bin/sonar-scanner /usr/local/bin/sonar-scanner

ENV SONAR_RUNNER_HOME=/usr/lib/sonar-scanner

COPY build/cicd/sonarqube/sonar-runner.properties /usr/lib/sonar-scanner/conf/sonar-scanner.properties

# ensure Sonar uses the provided Java for musl instead of a borked glibc one
RUN sed -i 's/use_embedded_jre=true/use_embedded_jre=false/g' /usr/lib/sonar-scanner/bin/sonar-scanner

# Separating ENTRYPOINT and CMD operations allows for core execution variables to
# be easily overridden by passing them in as part of the `docker run` command.
# This allows the default /usr/src base dir to be overridden by users as-needed.

# ENTRYPOINT ["sonar-scanner"]
CMD ["-Dsonar.projectBaseDir=/usr/src"]

# ==================== #
# Contents above copied from https://github.com/newtmitch/docker-sonar-scanner/blob/master/Dockerfile.sonarscanner-3.3.0-alpine,
# in order to build an arm64 supported image of newtmitch/sonar-scanner:3.3.0-alpine
# ==================== #

# FROM newtmitch/sonar-scanner:3.3.0-alpine
FROM caicloud/cyclone-base-openjdk:v1.0.0-arm64v8

LABEL maintainer="[email protected]"

ENV WORKDIR /workspace
WORKDIR $WORKDIR

RUN apk add jq

COPY ./build/cicd/sonarqube/entrypoint.sh /

ENTRYPOINT ["/entrypoint.sh"]
5 changes: 1 addition & 4 deletions build/resolver/git/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
FROM alpine:3.8
FROM caicloud/cyclone-base-alpine:v1.0.0

LABEL maintainer="[email protected]"

ENV WORKDIR /workspace
WORKDIR $WORKDIR

RUN apk update && \
apk add --no-cache ca-certificates git bash coreutils

COPY ./build/resolver/git/entrypoint.sh /

ENTRYPOINT ["/entrypoint.sh"]
Expand Down
5 changes: 1 addition & 4 deletions build/resolver/git/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
FROM arm64v8/alpine:3.8
FROM caicloud/cyclone-base-alpine:v1.0.0-arm64v8

LABEL maintainer="[email protected]"

ENV WORKDIR /workspace
WORKDIR $WORKDIR

RUN apk update && \
apk add --no-cache ca-certificates git bash coreutils

COPY ./build/resolver/git/entrypoint.sh /

ENTRYPOINT ["/entrypoint.sh"]
Expand Down
12 changes: 1 addition & 11 deletions build/resolver/image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
FROM alpine:3.8
FROM caicloud/cyclone-base-alpine:v1.0.0

LABEL maintainer="[email protected]"

ENV WORKDIR /workspace
ENV DOCKER_VERSION 18.03.1-ce
WORKDIR $WORKDIR

RUN apk add --no-cache curl && \
set -x && \
curl -L -o /tmp/docker-${DOCKER_VERSION}.tgz https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz && \
tar -xz -C /tmp -f /tmp/docker-${DOCKER_VERSION}.tgz && \
mv /tmp/docker/docker /usr/bin && \
rm -rf /tmp/docker && \
rm /tmp/docker-${DOCKER_VERSION}.tgz


COPY ./build/resolver/image/entrypoint.sh /

ENTRYPOINT ["/entrypoint.sh"]
Expand Down
11 changes: 2 additions & 9 deletions build/resolver/image/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
FROM arm64v8/alpine:3.8
FROM caicloud/cyclone-base-alpine:v1.0.0-arm64v8

LABEL maintainer="[email protected]"

ENV WORKDIR /workspace
ENV DOCKER_VERSION 18.03.1-ce

WORKDIR $WORKDIR

RUN apk add --no-cache curl && \
set -x && \
curl -L -o /tmp/docker-${DOCKER_VERSION}.tgz https://download.docker.com/linux/static/stable/aarch64/docker-${DOCKER_VERSION}.tgz && \
tar -xz -C /tmp -f /tmp/docker-${DOCKER_VERSION}.tgz && \
mv /tmp/docker/docker /usr/bin && \
rm -rf /tmp/docker && \
rm /tmp/docker-${DOCKER_VERSION}.tgz


COPY ./build/resolver/image/entrypoint.sh /
Expand Down
5 changes: 1 addition & 4 deletions build/resolver/svn/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
FROM alpine:3.8
FROM caicloud/cyclone-base-alpine:v1.0.0

LABEL maintainer="[email protected]"

ENV WORKDIR /workspace
WORKDIR $WORKDIR

RUN apk update && \
apk add --no-cache ca-certificates bash coreutils subversion

COPY ./build/resolver/svn/entrypoint.sh /

ENTRYPOINT ["/entrypoint.sh"]
Expand Down
5 changes: 1 addition & 4 deletions build/resolver/svn/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
FROM arm64v8/alpine:3.8
FROM caicloud/cyclone-base-alpine:v1.0.0-arm64v8

LABEL maintainer="[email protected]"

ENV WORKDIR /workspace
WORKDIR $WORKDIR

RUN apk update && \
apk add --no-cache ca-certificates bash coreutils subversion

COPY ./build/resolver/svn/entrypoint.sh /

ENTRYPOINT ["/entrypoint.sh"]
Expand Down
8 changes: 1 addition & 7 deletions build/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
FROM alpine:3.8
FROM caicloud/cyclone-base-alpine:v1.0.0

LABEL maintainer="[email protected]"

WORKDIR /root

RUN apk update && apk add ca-certificates && \
apk add --no-cache subversion && \
apk add tzdata && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone

# Copy cyclone server and stage templates
COPY bin/server /cyclone-server
COPY manifests/templates /root/templates
Expand Down
8 changes: 1 addition & 7 deletions build/server/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
FROM arm64v8/alpine:3.8
FROM caicloud/cyclone-base-alpine:v1.0.0-arm64v8

LABEL maintainer="[email protected]"

WORKDIR /root

RUN apk update && apk add ca-certificates && \
apk add --no-cache subversion && \
apk add tzdata && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone

# Copy cyclone server and stage templates
COPY bin/server /cyclone-server
COPY manifests/templates /root/templates
Expand Down
2 changes: 1 addition & 1 deletion build/toolbox/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.8
FROM caicloud/cyclone-base-alpine:v1.0.0

LABEL maintainer="[email protected]"

Expand Down
2 changes: 1 addition & 1 deletion build/toolbox/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM arm64v8/alpine:3.8
FROM caicloud/cyclone-base-alpine:v1.0.0-arm64v8

LABEL maintainer="[email protected]"

Expand Down
Loading