-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install publish tools in builder images (#29)
- Loading branch information
1 parent
cfb7f45
commit b6616e0
Showing
10 changed files
with
176 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,29 @@ | ||
### Building & Publishing Dockerfiles | ||
|
||
#### Logging in to registry.redhat.io | ||
|
||
1. Go to https://access.redhat.com/terms-based-registry/ and create an account. | ||
2. Login and create a service account. | ||
3. After receiving a token, run: | ||
|
||
``` shell | ||
docker login registry.redhat.io | ||
``` | ||
|
||
#### Building images for testing | ||
|
||
``` shell | ||
export IMAGE_NAME="image_name" # use one of the directory names in the dockerfiles directory (e.g. linux-builder) | ||
export DOCKERHUB_USERNAME="your_dockerhub_username_here" | ||
export TAG_NAME="${IMAGE_NAME}-${DOCKERHUB_USERNAME}" | ||
docker build . -f dockerfiles/linux-publisher/Dockerfile -t sensu/sensu-release:${TAG_NAME} | ||
docker push sensu/sensu-release:${TAG_NAME} | ||
``` | ||
|
||
#### Building images for release | ||
|
||
``` shell | ||
for i in `ls dockerfiles`; do docker build . -f dockerfiles/$i/Dockerfile -t sensu/sensu-release:$i; docker push sensu/sensu-release:$i; done | ||
export IMAGE_NAME="image_name" # use one of the directory names in the dockerfiles directory (e.g. linux-builder) | ||
docker build . -f dockerfiles/linux-publisher/Dockerfile -t sensu/sensu-release:${IMAGE_NAME} | ||
docker push sensu/sensu-release:${IMAGE_NAME} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,69 @@ | ||
FROM registry.access.redhat.com/ubi7/python-38:1 as python | ||
FROM registry.access.redhat.com/ubi7/go-toolset:1.13.4 | ||
|
||
LABEL name="sensu/sensu-release" \ | ||
maintainer="[email protected]" | ||
|
||
USER root | ||
|
||
ENV WORKSPACE_PATH="/workspace" | ||
ENV ARTIFACTS_PATH="${WORKSPACE_PATH}/artifacts" | ||
|
||
RUN mkdir -p $WORKSPACE_PATH | ||
RUN mkdir -p $ARTIFACTS_PATH | ||
# Install python3.8 | ||
COPY --from=python /opt/app-root/bin/python3.8 /opt/app-root/bin/python3.8 | ||
COPY --from=python /opt/app-root/bin/python3.8 /opt/app-root/bin/python3 | ||
COPY --from=python /opt/app-root/bin/python3.8 /opt/app-root/bin/python | ||
COPY --from=python /opt/app-root/lib/python3.8 /opt/app-root/lib/python3 | ||
COPY --from=python /opt/app-root/lib64/python3.8 /opt/app-root/lib64/python3 | ||
COPY --from=python /opt/app-root/bin/pip /opt/app-root/bin/pip | ||
COPY --from=python /opt/app-root/bin/pip /opt/app-root/bin/pip3 | ||
COPY --from=python /opt/app-root/bin/pip /opt/app-root/bin/pip3.8 | ||
|
||
# Install packages | ||
ENV SYSTEM_PKGS="openssl sudo" | ||
ENV PYTHON_PKGS="rh-python36" | ||
|
||
RUN INSTALL_PKGS="${SYSTEM_PKGS} ${PYTHON_PKGS}" && \ | ||
RUN INSTALL_PKGS="${SYSTEM_PKGS}" && \ | ||
yum install -y yum-utils && \ | ||
yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ | ||
rpm -V $INSTALL_PKGS && \ | ||
yum -y clean all --enablerepo='*' | ||
rpm -V $INSTALL_PKGS | ||
|
||
ENV GO111MODULE="on" | ||
ENV GOPROXY="https://proxy.golang.org" | ||
# Uninstall git and unstall newer git | ||
RUN yum -y --setopt=tsflags=nodocs install http://mirror.centos.org/centos/7/os/x86_64/Packages/pcre2-10.23-2.el7.x86_64.rpm | ||
RUN yum -y --setopt=tsflags=nodocs install http://mirror.centos.org/centos/7/os/x86_64/Packages/emacs-filesystem-24.3-23.el7.noarch.rpm | ||
RUN yum -y --setopt=tsflags=nodocs install http://mirror.centos.org/centos/7/os/x86_64/Packages/libsecret-0.18.6-1.el7.x86_64.rpm | ||
RUN yum -y --setopt=tsflags=nodocs install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm | ||
RUN yum -y --setopt=tsflags=nodocs install git | ||
RUN yum -y clean all --enablerepo='*' | ||
|
||
# Install aws-cli | ||
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" | ||
RUN unzip awscliv2.zip | ||
RUN ./aws/install | ||
|
||
# Install goreleaser | ||
RUN rpm -Uvh "https://github.com/goreleaser/goreleaser/releases/download/v0.136.0/goreleaser_amd64.rpm" | ||
|
||
# Set envvars & make dirs | ||
ENV WORKSPACE_PATH="/workspace" | ||
ENV ARTIFACTS_PATH="${WORKSPACE_PATH}/artifacts" | ||
ENV LOGS_PATH="${ARTIFACTS_PATH}/logs" | ||
ENV TOOLS_PATH="/tools" | ||
|
||
RUN mkdir -p $WORKSPACE_PATH | ||
RUN mkdir -p $ARTIFACTS_PATH | ||
RUN mkdir -p $LOGS_PATH | ||
RUN mkdir -p $TOOLS_PATH | ||
|
||
# Copy sensu-release tools to /tools | ||
COPY ci-common-functions.sh $TOOLS_PATH | ||
COPY post-packages-s3.sh $TOOLS_PATH | ||
COPY go.mod $TOOLS_PATH | ||
COPY go.sum $TOOLS_PATH | ||
ADD cmd $TOOLS_PATH/cmd | ||
|
||
# Build tools | ||
ENV GO111MODULE="on" | ||
ENV GOPROXY="https://proxy.golang.org" | ||
RUN export PATH=$PATH:$(dirname $(find /opt -name go -type f)) && \ | ||
cd $TOOLS_PATH && go build ./cmd/circleci-logs | ||
|
||
# Add circleci user | ||
RUN useradd --uid=3434 --user-group --create-home circleci | ||
RUN echo 'circleci ALL=NOPASSWD: ALL' >> /etc/sudoers.d/50-circleci | ||
|
@@ -37,11 +74,14 @@ RUN sudo -u circleci mkdir /home/circleci/project | |
RUN chown -R circleci:circleci $WORKSPACE_PATH | ||
RUN chown -R circleci:circleci $ARTIFACTS_PATH | ||
RUN chown -R circleci:circleci $APP_ROOT | ||
RUN chown -R circleci:circleci $LOGS_PATH | ||
RUN chown -R circleci:circleci $TOOLS_PATH | ||
RUN chmod +x $APP_ROOT/etc/scl_enable | ||
|
||
# Fix BASH_ENV | ||
RUN sed -e '/unset BASH_ENV PROMPT_COMMAND ENV/ s/^#*/#/' -i $APP_ROOT/etc/scl_enable | ||
|
||
USER circleci | ||
ENV HOME /home/circleci | ||
ENV TERM xterm-color | ||
WORKDIR $HOME/project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,60 @@ | ||
FROM registry.access.redhat.com/ubi8/python-38:1 as python | ||
FROM registry.access.redhat.com/ubi8/go-toolset:1.13.4 | ||
|
||
LABEL name="sensu/sensu-release" \ | ||
maintainer="[email protected]" | ||
|
||
USER root | ||
|
||
ENV WORKSPACE_PATH="/workspace" | ||
ENV ARTIFACTS_PATH="${WORKSPACE_PATH}/artifacts" | ||
|
||
RUN mkdir -p $WORKSPACE_PATH | ||
RUN mkdir -p $ARTIFACTS_PATH | ||
# Install python3.8 | ||
COPY --from=python /opt/app-root/bin/python3.8 /opt/app-root/bin/python3.8 | ||
COPY --from=python /opt/app-root/bin/python3.8 /opt/app-root/bin/python3 | ||
COPY --from=python /opt/app-root/bin/python3.8 /opt/app-root/bin/python | ||
COPY --from=python /opt/app-root/lib/python3.8 /opt/app-root/lib/python3 | ||
COPY --from=python /opt/app-root/lib64/python3.8 /opt/app-root/lib64/python3 | ||
COPY --from=python /opt/app-root/bin/pip /opt/app-root/bin/pip | ||
COPY --from=python /opt/app-root/bin/pip /opt/app-root/bin/pip3 | ||
COPY --from=python /opt/app-root/bin/pip /opt/app-root/bin/pip3.8 | ||
|
||
# Install packages | ||
ENV SYSTEM_PKGS="openssl sudo" | ||
ENV PYTHON_PKGS="python38" | ||
|
||
RUN INSTALL_PKGS="${SYSTEM_PKGS} ${PYTHON_PKGS}" && \ | ||
RUN INSTALL_PKGS="${SYSTEM_PKGS}" && \ | ||
yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ | ||
rpm -V $INSTALL_PKGS && \ | ||
yum -y clean all --enablerepo='*' | ||
|
||
ENV GO111MODULE="on" | ||
ENV GOPROXY="https://proxy.golang.org" | ||
# Install aws-cli | ||
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" | ||
RUN unzip awscliv2.zip | ||
RUN ./aws/install | ||
|
||
# Install goreleaser | ||
RUN rpm -Uvh "https://github.com/goreleaser/goreleaser/releases/download/v0.136.0/goreleaser_amd64.rpm" | ||
|
||
# Set envvars & make dirs | ||
ENV WORKSPACE_PATH="/workspace" | ||
ENV ARTIFACTS_PATH="${WORKSPACE_PATH}/artifacts" | ||
ENV LOGS_PATH="${ARTIFACTS_PATH}/logs" | ||
ENV TOOLS_PATH="/tools" | ||
|
||
RUN mkdir -p $WORKSPACE_PATH | ||
RUN mkdir -p $ARTIFACTS_PATH | ||
RUN mkdir -p $LOGS_PATH | ||
RUN mkdir -p $TOOLS_PATH | ||
|
||
# Copy sensu-release tools to /tools | ||
COPY ci-common-functions.sh $TOOLS_PATH | ||
COPY post-packages-s3.sh $TOOLS_PATH | ||
COPY go.mod $TOOLS_PATH | ||
COPY go.sum $TOOLS_PATH | ||
ADD cmd $TOOLS_PATH/cmd | ||
|
||
# Build tools | ||
ENV GO111MODULE="on" | ||
ENV GOPROXY="https://proxy.golang.org" | ||
RUN cd $TOOLS_PATH && go build ./cmd/circleci-logs | ||
|
||
# Add circleci user | ||
RUN useradd --uid=3434 --user-group --create-home circleci | ||
RUN echo 'circleci ALL=NOPASSWD: ALL' >> /etc/sudoers.d/50-circleci | ||
|
@@ -35,10 +64,13 @@ RUN sudo -u circleci mkdir /home/circleci/project | |
# Fix ownership | ||
RUN chown -R circleci:circleci $WORKSPACE_PATH | ||
RUN chown -R circleci:circleci $ARTIFACTS_PATH | ||
RUN chown -R circleci:circleci $LOGS_PATH | ||
RUN chown -R circleci:circleci $TOOLS_PATH | ||
|
||
# Fix BASH_ENV | ||
RUN sed -e '/unset BASH_ENV PROMPT_COMMAND ENV/ s/^#*/#/' -i $APP_ROOT/etc/scl_enable | ||
|
||
USER circleci | ||
ENV HOME /home/circleci | ||
ENV TERM xterm-color | ||
WORKDIR $HOME/project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.