Made it again about 40 MB smaller

This commit is contained in:
dor_pauli 2023-03-28 17:10:53 +02:00
parent a97fb808dc
commit 98f90a59f8
No known key found for this signature in database
GPG Key ID: B2F6B1E15963F107

View File

@ -1,44 +1,10 @@
# -------------------------------------------------------------------------------------------------------------- #
# ____ _ _ _ #
# | __ ) _ _ (_) | | __| | #
# | _ \ | | | | | | | | / _` | #
# | |_) | | |_| | | | | | | (_| | #
# |____/ \__,_| |_| |_| \__,_| #
# #
# -------------------------------------------------------------------------------------------------------------- #
FROM ubuntu:22.04 as build
FROM ubuntu:22.04
ENV OCS_VERSION 2.11.1
ENV OCS_VERSION=2.11.1 TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update && apt-get install -y \
wget \
curl \
make \
perl \
build-essential
RUN wget https://github.com/OCSInventory-NG/OCSInventory-ocsreports/releases/download/${OCS_VERSION}/OCSNG_UNIX_SERVER-${OCS_VERSION}.tar.gz -P /tmp && \
tar xzf /tmp/OCSNG_UNIX_SERVER-${OCS_VERSION}.tar.gz -C /tmp;
RUN cd /tmp/OCSNG_UNIX_SERVER-${OCS_VERSION}/Apache/ && \
perl Makefile.PL && \
make && \
make install
# -------------------------------------------------------------------------------------------------------------- #
# __ __ _ ___ _ _ #
# | \/ | / \ |_ _| | \ | | #
# | |\/| | / _ \ | | | \| | #
# | | | | / ___ \ | | | |\ | #
# |_| |_| /_/ \_\ |___| |_| \_| #
# #
# -------------------------------------------------------------------------------------------------------------- #
FROM ubuntu:22.04
LABEL Maintainer="contact@ocsinventory-ng.org" \
version="${OCS_VERSION}" \
description="OCS Inventory docker image"
ENV APACHE_RUN_USER=www-data APACHE_RUN_GROUP=www-data \
APACHE_LOG_DIR=/var/log/apache2 APACHE_PID_FILE=/var/run/apache2/apache2.pid APACHE_RUN_DIR=/var/run/apache2 APACHE_LOCK_DIR=/var/lock/apache2 \
@ -47,16 +13,15 @@ ENV APACHE_RUN_USER=www-data APACHE_RUN_GROUP=www-data \
OCS_PERLEXT_DIR=/etc/ocsinventory-server/perl/ OCS_PLUGINSEXT_DIR=/etc/ocsinventory-server/plugins/ \
OCS_SSL_ENABLED=0 OCS_SSL_WEB_MODE=DISABLED OCS_SSL_COM_MODE=DISABLED OCS_SSL_KEY=/path/to/key OCS_SSL_CERT=/path/to/cert OCS_SSL_CA=/path/to/ca \
OCS_INSTALL_ENABLED=0 TZ=Europe/Paris
ENV OCS_VERSION 2.11.1
LABEL Maintainer="contact@ocsinventory-ng.org" \
version="${OCS_VERSION}" \
description="OCS Inventory docker image"
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone ; \
apt-get update && apt-get install -y \
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
# install necessary packages
&& apt-get update && apt-get install --no-install-recommends -y \
wget \
curl \
make \
perl \
build-essential \
apache2 \
php \
libxml-simple-perl \
@ -77,20 +42,25 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone ;
php-xml \
php-zip \
php-gd \
php-ldap
php-ldap \
# build perl module
&& wget https://github.com/OCSInventory-NG/OCSInventory-ocsreports/releases/download/${OCS_VERSION}/OCSNG_UNIX_SERVER-${OCS_VERSION}.tar.gz -P /tmp \
&& tar xzf /tmp/OCSNG_UNIX_SERVER-${OCS_VERSION}.tar.gz -C /tmp \
&& cd /tmp/OCSNG_UNIX_SERVER-${OCS_VERSION}/Apache/ \
&& perl Makefile.PL \
&& make \
&& make install \
# remove unnecessary packages and apt cache
&& apt-get remove -y --purge wget curl make build-essential \
&& apt-get remove --purge --auto-remove -y && rm -rf /var/lib/apt/lists/* \
# Redirect Apache2 Logs to stdout e stderr
&& ln -sf /proc/self/fd/1 /var/log/apache2/access.log \
&& ln -sf /proc/self/fd/2 /var/log/apache2/error.log
VOLUME /var/lib/ocsinventory-reports /etc/ocsinventory-server /usr/share/ocsinventory-reports/ocsreports/extensions
EXPOSE 80
# Redirect Apache2 Logs to stdout e stderr
RUN ln -sf /proc/self/fd/1 /var/log/apache2/access.log && \
ln -sf /proc/self/fd/2 /var/log/apache2/error.log
# Copy the compiled files from the builder stage
COPY --from=build /tmp/OCSNG_UNIX_SERVER-$OCS_VERSION/ /tmp/OCSNG_UNIX_SERVER-$OCS_VERSION
COPY --from=build /usr/local/share/perl/ /usr/local/share/perl
COPY --from=build /usr/local/lib/x86_64-linux-gnu/perl/ /usr/local/lib/x86_64-linux-gnu/perl
COPY conf/ /tmp/conf
COPY ./docker-entrypoint.sh /docker-entrypoint.sh
COPY ./docker-entrypoint.d /docker-entrypoint.d