Skip to main content

A small program to optimize Dockerfiles

Project description

docker-optimizer allows collapsing multiple RUN layers into a single one. This way, you can use the docker caching for development, yet get fewer layers for the final container.

Installation

pip install docker-optimizer

Usage

Input Dockerfile.dev:

FROM python:3.8-slim-buster

#============================================================================
# Install requirements
#============================================================================
COPY requirements.txt /requirements.txt
RUN pip install -r /requirements.txt

#============================================================================
# Update the package list
#============================================================================
RUN apt-get update -y

#============================================================================
# Install certbot
#============================================================================
RUN apt-get install -y curl && \
    curl -LO https://dl.eff.org/certbot-auto && \
    mv certbot-auto /usr/local/bin && \
    chown root /usr/local/bin/certbot-auto && \
    chmod 755 /usr/local/bin/certbot-auto && \
    certbot-auto --install-only -n

#============================================================================
# cleanup package list
#============================================================================
RUN rm -rf /var/lib/apt/lists/*

COPY new-certificate* /usr/local/bin/

USER 1000
ENV LE_AUTO_SUDO=
WORKDIR /usr/local/bin
ENTRYPOINT ["python", "new-certificate.py"]
docker-optimizer Dockerfile.dev Dockerfile
# compiled by docker-optimizer
# https://github.com/bmustiata/docker-optimizer
from python:3.8-slim-buster
copy requirements.txt /requirements.txt
run pip install -r /requirements.txt && apt-get update -y && apt-get install -y curl &&     curl -LO https://dl.eff.org/certbot-auto &&     mv certbot-auto /usr/local/bin &&     chown root /usr/local/bin/certbot-auto &&     chmod 755 /usr/local/bin/certbot-auto &&     certbot-auto --install-only -n && rm -rf /var/lib/apt/lists/*
copy new-certificate* /usr/local/bin/
user 1000
env 'LE_AUTO_SUDO' ''
workdir /usr/local/bin
entrypoint ['python', 'new-certificate.py']

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docker-optimizer-1.1.0.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file docker-optimizer-1.1.0.tar.gz.

File metadata

  • Download URL: docker-optimizer-1.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.7

File hashes

Hashes for docker-optimizer-1.1.0.tar.gz
Algorithm Hash digest
SHA256 dfff5b9f3e60669faeced3fda0bd5960a40eb8017caa95b571b7641f6b72a78c
MD5 344fba809f1c6876a816d569e33a5717
BLAKE2b-256 e51fc8bbcdc2a04fcc190ded33ec923686033ea38a9daec73e4ecaf454054c7a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page