Skip to content

Commit

Permalink
Issue #230 Build on RHEL
Browse files Browse the repository at this point in the history
  • Loading branch information
jmelis committed Apr 24, 2018
1 parent 14d4cb0 commit 3167d80
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 8 deletions.
28 changes: 28 additions & 0 deletions Dockerfile.deploy.rhel
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM prod.registry.devshift.net/osio-prod/base/pcp:latest
LABEL maintainer "Devtools <[email protected]>"
LABEL author "Devtools <[email protected]>"
ENV LANG=en_US.utf8
ENV INSTALL_PREFIX=/usr/local/f8

# Create a non-root user and a group with the same name: "f8" USER_NAME=f8
ENV USER_NAME=f8
RUN useradd --no-create-home -s /bin/bash ${USER_NAME}

COPY out/fabric8-jenkins-proxy ${INSTALL_PREFIX}/bin/fabric8-jenkins-proxy
COPY static/html/index.html /opt/fabric8-jenkins-proxy/index.html

# Install little pcp pmcd server for metrics collection
# would prefer only pmcd, and not the /bin/pm*tools etc.
RUN mkdir -p /var/lib/pcp/config/pmda && \
chown -R ${USER_NAME} /etc/pcp /var/run/pcp /var/lib/pcp /var/log/pcp && \
chmod a+rw /var/lib/pcp/config/pmda && \
chmod -R ug+rw /etc/pcp /var/run/pcp /var/lib/pcp /var/log/pcp
COPY ./scripts/pcp/jenkins-proxy+pmcd.sh /jenkins-proxy+pmcd.sh
EXPOSE 44321

USER ${USER_NAME}

WORKDIR ${INSTALL_PREFIX}
ENTRYPOINT [ "/jenkins-proxy+pmcd.sh" ]

EXPOSE 8080
20 changes: 15 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
REGISTRY_URI = "push.registry.devshift.net"
REGISTRY_NS = "fabric8-services"
REGISTRY_IMAGE = "fabric8-jenkins-proxy"
REGISTRY_URL = ${REGISTRY_URI}/${REGISTRY_NS}/${REGISTRY_IMAGE}

ifeq ($(TARGET),rhel)
DOCKERFILE_DEPLOY := Dockerfile.deploy.rhel
REGISTRY_URL = ${REGISTRY_URI}/osio-prod/${REGISTRY_NS}/${REGISTRY_IMAGE}
else
DOCKERFILE_DEPLOY := Dockerfile.deploy
REGISTRY_URL = ${REGISTRY_URI}/${REGISTRY_NS}/${REGISTRY_IMAGE}
endif

IMAGE_TAG ?= $(shell git rev-parse --short HEAD)

BUILD_DIR = out
Expand Down Expand Up @@ -41,14 +49,16 @@ $(BUILD_DIR):
$(BUILD_DIR)/fabric8-jenkins-proxy: vendor $(BUILD_DIR) ## Builds the Linux binary for the container image $BUILD_DIR
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags="$(LD_FLAGS)" -o $(BUILD_DIR)/$(REGISTRY_IMAGE) ./cmd/fabric8-jenkins-proxy

login:
$(call check_defined, REGISTRY_USER, "You need to pass the registry user via REGISTRY_USER.")
$(call check_defined, REGISTRY_PASSWORD, "You need to pass the registry password via REGISTRY_PASSWORD.")
docker login -u $(REGISTRY_USER) -p $(REGISTRY_PASSWORD) $(REGISTRY_URI)

image: $(BUILD_DIR)/fabric8-jenkins-proxy ## Builds the fabric8-jenkins-proxy container image
docker build -t $(REGISTRY_URL) -f Dockerfile.deploy .
docker build -t $(REGISTRY_URL) -f $(DOCKERFILE_DEPLOY) .

.PHONY: push
push: image ## Pushes the container image to the registry
$(call check_defined, REGISTRY_USER, "You need to pass the registry user via REGISTRY_USER.")
$(call check_defined, REGISTRY_PASSWORD, "You need to pass the registry password via REGISTRY_PASSWORD.")
docker login -u $(REGISTRY_USER) -p $(REGISTRY_PASSWORD) $(REGISTRY_URI)
docker push $(REGISTRY_URL):latest
docker tag $(REGISTRY_URL):latest $(REGISTRY_URL):$(IMAGE_TAG)
docker push $(REGISTRY_URL):$(IMAGE_TAG)
Expand Down
7 changes: 4 additions & 3 deletions cico_build_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function setup_build_environment() {
[ -f inherit-env ] && . inherit-env

# We need to disable selinux for now, XXX
/usr/sbin/setenforce 0
/usr/sbin/setenforce 0 || :

yum -y install docker make golang git
service docker start
Expand All @@ -35,7 +35,7 @@ function setup_golang() {
# Show Go version
go version
# Setup GOPATH
mkdir $HOME/go $HOME/go/src $HOME/go/bin $HOME/go/pkg
mkdir -p $HOME/go $HOME/go/src $HOME/go/bin $HOME/go/pkg
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$PATH
}
Expand All @@ -59,9 +59,10 @@ setup_workspace

cd $GOPATH/src/github.com/fabric8-services/fabric8-jenkins-proxy
echo "HEAD of repository `git rev-parse --short HEAD`"
make login REGISTRY_USER=${DEVSHIFT_USERNAME} REGISTRY_PASSWORD=${DEVSHIFT_PASSWORD}
make all

if [[ "$JOB_NAME" = "devtools-fabric8-jenkins-proxy-build-master" ]]; then
TAG=$(echo ${GIT_COMMIT} | cut -c1-${DEVSHIFT_TAG_LEN})
make push REGISTRY_USER=${DEVSHIFT_USERNAME} REGISTRY_PASSWORD=${DEVSHIFT_PASSWORD} IMAGE_TAG=${TAG}
make push IMAGE_TAG=${TAG}
fi

0 comments on commit 3167d80

Please sign in to comment.