Cleanup on arm64 dockerfile

This commit is contained in:
Loup-Garou911XD 2024-06-17 07:25:12 +05:30
parent a526c0a0fc
commit 6be9e270da
2 changed files with 25 additions and 42 deletions

View File

@ -10,10 +10,11 @@ ARG base_image=ubuntu:latest
# Start with the base image # Start with the base image
FROM ${base_image} AS builder FROM ${base_image} AS builder
# Renew the arg # Renew the args
ARG headless_build ARG headless_build
ARG cmake_build_type ARG cmake_build_type
# Environment settings
ENV LANG=en_US.utf8 ENV LANG=en_US.utf8
ENV LANGUAGE=en_US ENV LANGUAGE=en_US
ENV LC_ALL=en_US.utf8 ENV LC_ALL=en_US.utf8
@ -40,6 +41,7 @@ RUN apt-get update -y && \
# Copy source code # Copy source code
COPY ./ /ballistica COPY ./ /ballistica
# Set the working directory
WORKDIR /ballistica WORKDIR /ballistica
# Compile the application # Compile the application
@ -58,12 +60,13 @@ RUN mkdir /ballistica_cmake && \
# Create a new stage for the runtime environment # Create a new stage for the runtime environment
FROM ${base_image} FROM ${base_image}
# Environment settings
ENV LANG en_US.utf8 ENV LANG en_US.utf8
ENV LANGUAGE=en_US ENV LANGUAGE=en_US
ENV LC_ALL=en_US.utf8 ENV LC_ALL=en_US.utf8
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
# Renew the arg # Renew the args
ARG headless_build ARG headless_build
ENV HEADLESS_BUILD=${headless_build} ENV HEADLESS_BUILD=${headless_build}
ARG cmake_build_type ARG cmake_build_type
@ -72,7 +75,7 @@ LABEL BOMBSQUAD_BUILD_TYPE=${cmake_build_type}
# Install runtime dependencies # Install runtime dependencies
RUN apt-get update -y && \ RUN apt-get update -y && \
apt-get install -y \ apt-get install -y \
python3.12-dev && \ python3.12-dev && \
if [ "$HEADLESS_BUILD" = "0" ]; then \ if [ "$HEADLESS_BUILD" = "0" ]; then \
apt-get install -y \ apt-get install -y \
@ -82,12 +85,13 @@ RUN apt-get update -y && \
libopenal-dev; \ libopenal-dev; \
fi && \ fi && \
rm -rf /var/lib/apt/lists/* && \ rm -rf /var/lib/apt/lists/* && \
python3.12 -c 'import uuid; print(uuid.uuid4())' > /etc/machine-id python3.12 -c "import uuid; print(uuid.uuid4())" > /etc/machine-id
# Copy the compiled application from the builder stage # Copy the compiled application from the builder stage
COPY --from=builder /ballistica_cmake \ COPY --from=builder /ballistica_cmake \
/home/ubuntu/ballistica /home/ubuntu/ballistica
# Set the working directory
WORKDIR /home/ubuntu/ballistica WORKDIR /home/ubuntu/ballistica
RUN ln -s ballisticakit* run RUN ln -s ballisticakit* run

View File

@ -10,31 +10,19 @@ ARG base_image=ubuntu:latest
# Start with the base image # Start with the base image
FROM --platform=linux/arm64 ${base_image} AS builder FROM --platform=linux/arm64 ${base_image} AS builder
# Renew the ARGs # Renew the args
ARG headless_build ARG headless_build
ARG cmake_build_type ARG cmake_build_type
# Environment settings # Environment settings
ENV LANG en_US.utf8 ENV LANG=en_US.utf8
ENV LANGUAGE=en_US ENV LANGUAGE=en_US
ENV LC_ALL=en_US.utf8
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
ENV CMAKE_BUILD_TYPE=${cmake_build_type} ENV CMAKE_BUILD_TYPE=${cmake_build_type}
ENV HEADLESS_BUILD=${headless_build} ENV HEADLESS_BUILD=${headless_build}
# Enable ARM64 architecture and update package lists # Install build dependencies
RUN dpkg --add-architecture arm64 && apt-get update -y
# Install necessary tools to create users and groups
RUN apt-get install -y adduser \
&& apt-cache search clang-tools
# Configure dpkg to skip systemd post-installation scripts
RUN mkdir -p /etc/systemd/system && \
echo "exit 0" > /usr/sbin/policy-rc.d && chmod +x /usr/sbin/policy-rc.d && \
apt-get install -y --no-install-recommends \
# testing
clang
RUN apt-get install -y --no-install-recommends \ RUN apt-get install -y --no-install-recommends \
python3.12-dev \ python3.12-dev \
python3.12-venv \ python3.12-venv \
@ -46,16 +34,16 @@ RUN apt-get install -y --no-install-recommends \
curl \ curl \
rsync \ rsync \
clang-format \ clang-format \
clang \
cmake \ cmake \
libvorbis-dev \ libvorbis-dev \
build-essential \ build-essential
&& rm /usr/sbin/policy-rc.d
# Copy source code # Copy source code
COPY ./ /home/ubuntu/ballistica COPY ./ /ballistica
# Set the working directory # Set the working directory
WORKDIR /home/ubuntu/ballistica WORKDIR /ballistica
# Compile the application # Compile the application
RUN mkdir /ballistica_cmake && \ RUN mkdir /ballistica_cmake && \
@ -75,25 +63,17 @@ FROM --platform=linux/arm64 ${base_image}
# Environment settings # Environment settings
ENV LANG en_US.utf8 ENV LANG en_US.utf8
ENV LANGUAGE=en_US ENV LANGUAGE=en_US
ENV LC_ALL=en_US.utf8
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
# Renew the ARGs # Renew the args
ARG headless_build ARG headless_build
ENV HEADLESS_BUILD=${headless_build} ENV HEADLESS_BUILD=${headless_build}
ARG cmake_build_type ARG cmake_build_type
LABEL BOMBSQUAD_BUILD_TYPE=${cmake_build_type} LABEL BOMBSQUAD_BUILD_TYPE=${cmake_build_type}
# Install necessary tools to create users and groups # Install runtime dependencies
RUN apt-get update -y && apt-get install -y adduser RUN apt-get update -y && \
# Pre-create necessary users and groups to avoid systemd configuration errors
RUN addgroup --system systemd-journal && \
adduser --system --no-create-home --ingroup systemd-journal systemd-network
# Configure dpkg to skip systemd post-installation scripts
RUN mkdir -p /etc/systemd/system && \
echo "exit 0" > /usr/sbin/policy-rc.d && chmod +x /usr/sbin/policy-rc.d && \
apt-get update -y && \
apt-get install -y \ apt-get install -y \
python3.12-dev && \ python3.12-dev && \
if [ "$HEADLESS_BUILD" = "0" ]; then \ if [ "$HEADLESS_BUILD" = "0" ]; then \
@ -104,14 +84,13 @@ RUN mkdir -p /etc/systemd/system && \
libopenal-dev; \ libopenal-dev; \
fi && \ fi && \
rm -rf /var/lib/apt/lists/* && \ rm -rf /var/lib/apt/lists/* && \
python3.12 -c "import uuid;print(uuid.uuid4())" > /etc/machine-id && \ python3.12 -c "import uuid; print(uuid.uuid4())" > /etc/machine-id
rm /usr/sbin/policy-rc.d
# Copy the compiled application from the builder stage # Copy the compiled application from the builder stage
COPY --from=builder /ballistica_cmake \ COPY --from=builder /ballistica_cmake \
/home/ubuntu/ballistica /home/ubuntu/ballistica
# Set the working directory # Set the working directory
WORKDIR /home/ubuntu/ballistica WORKDIR /home/ubuntu/ballistica
RUN ln -s ballisticakit* run RUN ln -s ballisticakit* run