Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring Dockerfile #108

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
dockerfile: Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: ACAPARCH=${{ matrix.arch }}
build-args: ARCH=${{ matrix.arch }}
outputs: "type=local,dest=build"
- name: Get name of EAP-file
id: get_eap_file_name
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build*/
tls/
tmp/
dockerd
docker-compose
Expand Down
60 changes: 40 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,40 +1,47 @@
# syntax=docker/dockerfile:1

ARG DOCKER_VERSION=26.0.0
ARG DOCKER_IMAGE_VERSION=26.0.0
ARG DOCKER_COMPOSE_VERSION=v2.25.0
ARG PROCPS_VERSION=v3.3.17

ARG REPO=axisecp
ARG ACAPARCH=armv7hf
ARG ARCH=armv7hf

ARG VERSION=1.13
ARG UBUNTU_VERSION=22.04
ARG NATIVE_SDK=acap-native-sdk

FROM ${REPO}/${NATIVE_SDK}:${VERSION}-${ACAPARCH}-ubuntu${UBUNTU_VERSION} as build_image
FROM ${REPO}/${NATIVE_SDK}:${VERSION}-${ARCH}-ubuntu${UBUNTU_VERSION} AS sdk_image

FROM build_image AS ps
ARG PROCPS_VERSION=v3.3.17
ARG BUILD_DIR=/build
ARG EXPORT_DIR=/export
FROM sdk_image AS build_image

# hadolint ignore=DL3009
RUN <<EOF
apt-get update
apt-get -q install -y -f --no-install-recommends \
automake \
autopoint \
gettext \
git \
libtool
libtool
ln -s /usr/bin/libtoolize /usr/bin/libtool

EOF

FROM build_image AS ps

ARG PROCPS_VERSION
ARG BUILD_DIR=/build
ARG EXPORT_DIR=/export

WORKDIR $BUILD_DIR
RUN git clone --depth 1 -b $PROCPS_VERSION 'https://gitlab.com/procps-ng/procps' .

ARG BUILD_CACHE=build.cache
RUN echo ac_cv_func_realloc_0_nonnull=yes >$BUILD_CACHE \
&& echo ac_cv_func_malloc_0_nonnull=yes >>$BUILD_CACHE
RUN <<EOF
echo ac_cv_func_realloc_0_nonnull=yes >$BUILD_CACHE
echo ac_cv_func_malloc_0_nonnull=yes >>$BUILD_CACHE
EOF

RUN <<EOF
. /opt/axis/acapsdk/environment-setup*
./autogen.sh
Expand All @@ -49,25 +56,26 @@ EOF
WORKDIR $EXPORT_DIR
RUN cp $BUILD_DIR/ps/pscommand ps

FROM build_image as build
FROM sdk_image AS docker-binaries

ARG DOCKER_VERSION
WORKDIR /download

ARG ARCH
ARG DOCKER_IMAGE_VERSION
ARG DOCKER_COMPOSE_VERSION
ARG ACAPARCH

COPY app /opt/app
COPY --from=ps /export/ps /opt/app
RUN echo ${DOCKER_COMPOSE_VERSION}

# Get docker* binaries and scripts
# Download and extract dockerd and its dependencies
RUN <<EOF
if [ "$ACAPARCH" = "armv7hf" ]; then
if [ "$ARCH" = "armv7hf" ]; then
export DOCKER_ARCH="armhf";
export DOCKER_COMPOSE_ARCH="armv7";
elif [ "$ACAPARCH" = "aarch64" ]; then
elif [ "$ARCH" = "aarch64" ]; then
export DOCKER_ARCH="aarch64";
export DOCKER_COMPOSE_ARCH="aarch64";
fi;
curl -Lo docker_binaries.tgz "https://download.docker.com/linux/static/stable/${DOCKER_ARCH}/docker-${DOCKER_VERSION}.tgz" ;
curl -Lo docker_binaries.tgz "https://download.docker.com/linux/static/stable/${DOCKER_ARCH}/docker-${DOCKER_IMAGE_VERSION}.tgz" ;
tar -xz -f docker_binaries.tgz --strip-components=1 docker/docker ;
tar -xz -f docker_binaries.tgz --strip-components=1 docker/dockerd ;
tar -xz -f docker_binaries.tgz --strip-components=1 docker/docker-init ;
Expand All @@ -76,7 +84,19 @@ RUN <<EOF
chmod +x docker-compose
EOF

FROM sdk_image AS build

WORKDIR /opt/app

COPY app .
COPY --from=ps /export/ps .
COPY --from=docker-binaries \
/download/dockerd \
/download/docker-init \
/download/docker-proxy \
/download/docker \
/download/docker-compose ./

RUN <<EOF
. /opt/axis/acapsdk/environment-setup*
acap-build . \
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ Following are the possible values of `Status`:
To build the Docker Compose ACAP use docker buildx with the provided Dockerfile:

```sh
# Build Docker ACAP image
docker buildx build --file Dockerfile --tag docker-acap-with-compose:<ARCH> --build-arg ACAPARCH=<ARCH> --output <build-folder> .
# Build Docker Compose ACAP image
docker buildx build --file Dockerfile --tag docker-acap-with-compose:<ARCH> --build-arg ARCH=<ARCH> --output <build-folder> .
```

where `<ARCH>` is either `armv7hf` or `aarch64`. `<build-folder>` is the path to an output folder
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ done

# Build and copy out the acap
# shellcheck disable=SC2086
docker buildx build --build-arg ACAPARCH="$arch" \
docker buildx build --build-arg ARCH="$arch" \
--build-arg HTTP_PROXY="${HTTP_PROXY:-}" \
--build-arg HTTPS_PROXY="${HTTPS_PROXY:-}" \
--file Dockerfile \
Expand Down