Rework dockerfile to reduce uneeded builds if not compiling

This commit is contained in:
QuantumEntangledAndy authored and Andrew King committed 2023-01-09 15:02:57 +07:00
1 parent e5583e697a
commit aead6ccbff
2 files changed
+18 -14

No files matched your search

+3 -2
View File
@@ -198,6 +198,7 @@ jobs:
run: |
mkdir linux
mkdir linux/arm
mkdir linux/arm64
- name: Download Linux x86_64
uses: actions/download-artifact@v3
with:
@@ -212,7 +213,7 @@ jobs:
uses: actions/download-artifact@v3
with:
name: release-arm64-buster
path: linux/arm64
path: linux/arm64/v8
- name: Download Linux i386
uses: actions/download-artifact@v3
with:
@@ -222,7 +223,7 @@ jobs:
if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/386
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/386
push: true
file: Dockerfile
tags: ${{ steps.tags.outputs.TAGS }}
+15 -12
View File
@@ -8,25 +8,28 @@ FROM docker.io/rust:slim-buster AS build
ARG TARGETPLATFORM
ENV DEBIAN_FRONTEND=noninteractive
# hadolint ignore=DL3008
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
libgstrtspserver-1.0-dev \
libgstreamer1.0-dev \
libgtk2.0-dev \
libglib2.0-dev && \
apt-get clean -y && rm -rf /var/lib/apt/lists/*
WORKDIR /usr/local/src/neolink
# Build the main program or copy from github build ones
COPY . /usr/local/src/neolink
RUN echo "TARGETPLATFORM; ${TARGETPLATFORM}"; \
# Build the main program or copy from artifact
# hadolint ignore=DL3008
RUN echo "TARGETPLATFORM: ${TARGETPLATFORM}"; \
if [ -f "${TARGETPLATFORM}/neolink" ]; then \
echo "Restoring from artifact"; \
mkdir -p /usr/local/src/neolink/target/release/; \
cp "${TARGETPLATFORM}/neolink" "/usr/local/src/neolink/target/release/neolink"; \
else \
echo "Building from scratch"; \
apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
libgstrtspserver-1.0-dev \
libgstreamer1.0-dev \
libgtk2.0-dev \
libglib2.0-dev && \
apt-get clean -y && rm -rf /var/lib/apt/lists/* ; \
cargo build --release; \
fi