Skip to content

Commit

Permalink
chore: Reduce size of docker image (#444)
Browse files Browse the repository at this point in the history
* chore: Reduce size of docker image

* chore: Add org.opencontainers.image.description field

* chore: Update base image to use generic versions
  • Loading branch information
titom73 authored Nov 8, 2023
1 parent 2e1d776 commit b374e7b
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 3 deletions.
93 changes: 93 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Git
.git
.gitignore
.gitattributes


# CI
.codeclimate.yml
.travis.yml
.taskcluster.yml

# Docker
docker-compose.yml
Dockerfile
.docker
.dockerignore

# Byte-compiled / optimized / DLL files
**/__pycache__/
**/*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Virtual environment
.env
.venv/
venv/

# PyCharm
.idea

# Python mode for VIM
.ropeproject
**/.ropeproject

# Vim swap files
**/*.swp

# VS Code
.vscode/

tests/**
examples/**

21 changes: 18 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
ARG PYTHON_VER=3.9
ARG IMG_OPTION=alpine

FROM python:${PYTHON_VER}-slim
### BUILDER

FROM python:${PYTHON_VER}-${IMG_OPTION} as BUILDER

RUN pip install --upgrade pip

WORKDIR /local
COPY . /local

ENV PYTHONPATH=/local
RUN pip --no-cache-dir install .
ENV PATH=$PATH:/root/.local/bin

RUN pip --no-cache-dir install --user .

# ----------------------------------- #

### BASE

FROM python:${PYTHON_VER}-${IMG_OPTION} as BASE

# Opencontainer labels
# Labels version and revision will be updating
Expand All @@ -18,6 +29,7 @@ RUN pip --no-cache-dir install .
# Doc: https://docs.docker.com/engine/reference/commandline/run/#label
LABEL "org.opencontainers.image.title"="anta" \
"org.opencontainers.artifact.description"="network-test-automation in a Python package and Python scripts to test Arista devices." \
"org.opencontainers.image.description"="network-test-automation in a Python package and Python scripts to test Arista devices." \
"org.opencontainers.image.source"="https://github.com/arista-netdevops-community/anta" \
"org.opencontainers.image.url"="https://www.anta.ninja" \
"org.opencontainers.image.documentation"="https://www.anta.ninja" \
Expand All @@ -28,4 +40,7 @@ LABEL "org.opencontainers.image.title"="anta" \
"org.opencontainers.image.revision"="dev" \
"org.opencontainers.image.version"="dev"

ENTRYPOINT [ "/usr/local/bin/anta" ]
COPY --from=BUILDER /root/.local/ /root/.local
ENV PATH=$PATH:/root/.local/bin

ENTRYPOINT [ "/root/.local/bin/anta" ]

0 comments on commit b374e7b

Please sign in to comment.