Skip to content

Instantly share code, notes, and snippets.

@fabianvf
Created June 27, 2019 18:22
Show Gist options
  • Save fabianvf/aa415d5c698d3fbed942f4459c04b2c0 to your computer and use it in GitHub Desktop.
Save fabianvf/aa415d5c698d3fbed942f4459c04b2c0 to your computer and use it in GitHub Desktop.
FROM openshift/origin-release:golang-1.11 AS builder
WORKDIR /go/src/github.com/operator-framework/operator-sdk
COPY . .
RUN make build/operator-sdk-dev-x86_64-linux-gnu VERSION=dev
ENV GO111MODULE=on
RUN build/operator-sdk-dev-x86_64-linux-gnu new tmp \
--type=ansible \
--kind=Tmp \
--api-version=tmp.example.com/v1 \
&& cd tmp \
&& ../build/operator-sdk-dev-x86_64-linux-gnu migrate
FROM registry.access.redhat.com/ubi8/python-27
USER 0
RUN mkdir -p /etc/ansible \
&& echo "localhost ansible_connection=local" > /etc/ansible/hosts \
&& echo '[defaults]' > /etc/ansible/ansible.cfg \
&& echo 'roles_path = /opt/ansible/roles' >> /etc/ansible/ansible.cfg \
&& echo 'library = /usr/share/ansible/openshift' >> /etc/ansible/ansible.cfg
ENV OPERATOR=/usr/local/bin/ansible-operator \
USER_UID=1001 \
USER_NAME=ansible-operator\
HOME=/opt/ansible
# Install python dependencies
RUN pip install --no-cache-dir ansible-runner ansible-runner-http openshift \
&& yum remove -y python-devel gcc \
&& yum clean all \
&& rm -rf /var/cache/yum
COPY --from=builder /go/src/github.com/operator-framework/operator-sdk/build/operator-sdk-dev-x86_64-linux-gnu ${OPERATOR}
COPY --from=builder /go/src/github.com/operator-framework/operator-sdk/tmp/library/k8s_status.py /usr/share/ansible/openshift/
# Ensure directory permissions are properly set
RUN mkdir -p ${HOME}/.ansible/tmp \
&& chown -R ${USER_UID}:0 ${HOME} \
&& chmod -R ug+rwx ${HOME}
ADD https://github.com/krallin/tini/releases/latest/download/tini /tini
RUN chmod +x /tini
ENTRYPOINT ["/tini", "--", "bash", "-c", "${OPERATOR} run ansible --watches-file=/opt/ansible/watches.yaml $@"]
USER 1001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment