reduce image size by setting permissions at copy stage

This commit is contained in:
Devlin Cashman
2022-12-17 20:35:31 -05:00
parent ca9315314a
commit c7abe29762
2 changed files with 15 additions and 20 deletions

View File

@@ -8,10 +8,6 @@ Dockerfile
dockerfiles/LICENSE dockerfiles/LICENSE
dockerfiles/README.md dockerfiles/README.md
docs docs
install/pialert_install.sh
install/pialert_install_no_webserver.sh
install/pialert_uninstall.sh
install/pialert_update.sh
LICENSE.txt LICENSE.txt
README.md README.md
tar CONTRIBUTING

View File

@@ -15,27 +15,26 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/* \ && rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/www/html \ && rm -rf /var/www/html \
&& ln -s /home/pi/pialert/front /var/www/html && ln -s /home/pi/pialert/front /var/www/html
# create pi user and group
# now creating user # add root and www-data to pi group so they can r/w files and db
RUN groupadd --gid "${USER_GID}" "${USER}" && \ RUN groupadd --gid "${USER_GID}" "${USER}" && \
useradd \ useradd \
--uid ${USER_ID} \ --uid ${USER_ID} \
--gid ${USER_GID} \ --gid ${USER_GID} \
--create-home \ --create-home \
--shell /bin/bash \ --shell /bin/bash \
${USER} ${USER} && \
usermod -a -G ${USER_GID} root && \
usermod -a -G ${USER_GID} www-data
COPY . /home/pi/pialert COPY --chmod=775 --chown=${USER_ID}:${USER_GID} . /home/pi/pialert/
# Pi.Alert # Pi.Alert
RUN rm /etc/nginx/sites-available/default \ RUN rm /etc/nginx/sites-available/default \
&& ln -s /home/pi/pialert/install/default /etc/nginx/sites-available/default \ && ln -s /home/pi/pialert/install/default /etc/nginx/sites-available/default \
&& sed -ie 's/listen 80/listen '${PORT}'/g' /etc/nginx/sites-available/default \ && sed -ie 's/listen 80/listen '${PORT}'/g' /etc/nginx/sites-available/default \
# run the hardware vendors update # run the hardware vendors update
&& /home/pi/pialert/back/update_vendors.sh && /home/pi/pialert/back/update_vendors.sh
# it's easy for permissions set in Git to be overridden, so doing it manually CMD ["/home/pi/pialert/dockerfiles/start.sh"]
RUN chmod -R a+rxw /home/pi/pialert/
CMD ["/home/pi/pialert/dockerfiles/start.sh"]