mirror of
https://github.com/esphome/esphome.git
synced 2024-11-21 22:48:10 +01:00
Install python requirements after apt ones for better caching (#2349)
* Install python requirements after apt ones for better caching * Fix buildkit caching works differently
This commit is contained in:
parent
7452ef23b1
commit
2d7f8b3bdf
2 changed files with 21 additions and 10 deletions
|
@ -51,17 +51,17 @@ RUN \
|
||||||
&& platformio settings set check_platforms_interval 1000000 \
|
&& platformio settings set check_platforms_interval 1000000 \
|
||||||
&& mkdir -p /piolibs
|
&& mkdir -p /piolibs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ======================= docker-type image =======================
|
||||||
|
FROM base AS docker
|
||||||
|
|
||||||
# First install requirements to leverage caching when requirements don't change
|
# First install requirements to leverage caching when requirements don't change
|
||||||
COPY requirements.txt requirements_optional.txt docker/platformio_install_deps.py platformio.ini /
|
COPY requirements.txt requirements_optional.txt docker/platformio_install_deps.py platformio.ini /
|
||||||
RUN \
|
RUN \
|
||||||
pip3 install --no-cache-dir -r /requirements.txt -r /requirements_optional.txt \
|
pip3 install --no-cache-dir -r /requirements.txt -r /requirements_optional.txt \
|
||||||
&& /platformio_install_deps.py /platformio.ini
|
&& /platformio_install_deps.py /platformio.ini
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ======================= docker-type image =======================
|
|
||||||
FROM base AS docker
|
|
||||||
|
|
||||||
# Copy esphome and install
|
# Copy esphome and install
|
||||||
COPY . /esphome
|
COPY . /esphome
|
||||||
RUN pip3 install --no-cache-dir -e /esphome
|
RUN pip3 install --no-cache-dir -e /esphome
|
||||||
|
@ -104,6 +104,12 @@ ARG BUILD_VERSION=dev
|
||||||
# Copy root filesystem
|
# Copy root filesystem
|
||||||
COPY docker/hassio-rootfs/ /
|
COPY docker/hassio-rootfs/ /
|
||||||
|
|
||||||
|
# First install requirements to leverage caching when requirements don't change
|
||||||
|
COPY requirements.txt requirements_optional.txt docker/platformio_install_deps.py platformio.ini /
|
||||||
|
RUN \
|
||||||
|
pip3 install --no-cache-dir -r /requirements.txt -r /requirements_optional.txt \
|
||||||
|
&& /platformio_install_deps.py /platformio.ini
|
||||||
|
|
||||||
# Copy esphome and install
|
# Copy esphome and install
|
||||||
COPY . /esphome
|
COPY . /esphome
|
||||||
RUN pip3 install --no-cache-dir -e /esphome
|
RUN pip3 install --no-cache-dir -e /esphome
|
||||||
|
@ -141,5 +147,10 @@ RUN \
|
||||||
/var/{cache,log}/* \
|
/var/{cache,log}/* \
|
||||||
/var/lib/apt/lists/*
|
/var/lib/apt/lists/*
|
||||||
|
|
||||||
|
COPY requirements.txt requirements_optional.txt docker/platformio_install_deps.py platformio.ini /
|
||||||
|
RUN \
|
||||||
|
pip3 install --no-cache-dir -r /requirements.txt -r /requirements_optional.txt \
|
||||||
|
&& /platformio_install_deps.py /platformio.ini
|
||||||
|
|
||||||
VOLUME ["/esphome"]
|
VOLUME ["/esphome"]
|
||||||
WORKDIR /esphome
|
WORKDIR /esphome
|
||||||
|
|
|
@ -109,9 +109,9 @@ def main():
|
||||||
# 1. pull cache image
|
# 1. pull cache image
|
||||||
params = DockerParams.for_type_arch(args.build_type, args.arch)
|
params = DockerParams.for_type_arch(args.build_type, args.arch)
|
||||||
cache_tag = {
|
cache_tag = {
|
||||||
CHANNEL_DEV: "dev",
|
CHANNEL_DEV: "cache-dev",
|
||||||
CHANNEL_BETA: "beta",
|
CHANNEL_BETA: "cache-beta",
|
||||||
CHANNEL_RELEASE: "latest",
|
CHANNEL_RELEASE: "cache-latest",
|
||||||
}[channel]
|
}[channel]
|
||||||
cache_img = f"ghcr.io/{params.build_to}:{cache_tag}"
|
cache_img = f"ghcr.io/{params.build_to}:{cache_tag}"
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ def main():
|
||||||
"docker", "buildx", "build",
|
"docker", "buildx", "build",
|
||||||
"--build-arg", f"BASEIMGTYPE={params.baseimgtype}",
|
"--build-arg", f"BASEIMGTYPE={params.baseimgtype}",
|
||||||
"--build-arg", f"BUILD_VERSION={args.tag}",
|
"--build-arg", f"BUILD_VERSION={args.tag}",
|
||||||
"--cache-from", cache_img,
|
"--cache-from", f"type=registry,ref={cache_img}",
|
||||||
"--file", "docker/Dockerfile",
|
"--file", "docker/Dockerfile",
|
||||||
"--platform", params.platform,
|
"--platform", params.platform,
|
||||||
"--target", params.target,
|
"--target", params.target,
|
||||||
|
@ -131,7 +131,7 @@ def main():
|
||||||
for img in imgs:
|
for img in imgs:
|
||||||
cmd += ["--tag", img]
|
cmd += ["--tag", img]
|
||||||
if args.push:
|
if args.push:
|
||||||
cmd.append("--push")
|
cmd += ["--push", "--cache-to", f"type=registry,ref={cache_img},mode=max"]
|
||||||
|
|
||||||
run_command(*cmd, ".")
|
run_command(*cmd, ".")
|
||||||
elif args.command == "manifest":
|
elif args.command == "manifest":
|
||||||
|
|
Loading…
Reference in a new issue