Last active
September 1, 2020 13:51
-
-
Save monokal/88ede52c21d6fe0cea5e929faab9e361 to your computer and use it in GitHub Desktop.
An example Dockerfile which spits out an RPM package on build.
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
FROM centos:centos7 | |
# Yum packages to install. | |
ENV YUM_PACKAGES \ | |
which \ | |
gcc \ | |
libffi-devel \ | |
openssl-devel \ | |
git \ | |
ruby-devel \ | |
python-devel \ | |
rubygems \ | |
rpm-build \ | |
make \ | |
curl \ | |
python-setuptools \ | |
python-setuptools-devel | |
# Gems to install. | |
ENV GEM_PACKAGES \ | |
fpm | |
# fpm argument vars. | |
ENV PACKAGE_NAME "MyPackage" | |
ENV PACKAGE_VERSION "1.0.0-0" | |
ENV PACKAGE_ARCH "noarch" | |
ENV WORKSPACE_PATH "/tmp" | |
ENV PACKAGE_INSTALL_PATH "/opt" | |
# Install YUM packages. | |
RUN yum makecache && \ | |
yum install -y $YUM_PACKAGES | |
# Install Gems. | |
RUN gem install $GEM_PACKAGES | |
# Install pip. | |
RUN curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py" && \ | |
python get-pip.py | |
# Create the workspace and output directories. | |
RUN mkdir -p "${WORKSPACE_PATH}${PACKAGE_INSTALL_PATH}" && \ | |
mkdir /output | |
WORKDIR "${WORKSPACE_PATH}" | |
ADD $PACKAGE_NAME "${PACKAGE_INSTALL_PATH#/}/${PACKAGE_NAME}" && \ | |
fpm -f \ | |
--verbose \ | |
-t rpm \ | |
-s python \ | |
--provides $PACKAGE_NAME \ | |
-n $PACKAGE_NAME \ | |
-v $PACKAGE_VERSION \ | |
-a all \ | |
-p "/output/${PACKAGE_NAME}-${PACKAGE_VERSION}.${PACKAGE_ARCH}.rpm" \ | |
--before-install "${PACKAGE_INSTALL_PATH#/}/${PACKAGE_NAME}/before-install.sh" \ | |
--after-install "${PACKAGE_INSTALL_PATH#/}/${PACKAGE_NAME}/after-install.sh" \ | |
-d 'gcc' \ | |
-d 'libffi-devel' \ | |
-d 'openssl-devel' \ | |
-d 'python-setuptools' \ | |
-d 'python-devel' \ | |
-d 'python-urllib3' \ | |
"${PACKAGE_INSTALL_PATH#/}/${PACKAGE_NAME}/setup.py" | |
# The RPM should extract our Python somewhere like: | |
# /usr/lib/python2.7/site-packages/${PACKAGE_NAME}/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment