Skip to content

Commit

Permalink
Fix Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
DTTerastar committed Oct 7, 2024
1 parent 5801169 commit 1f36587
Showing 1 changed file with 33 additions and 24 deletions.
57 changes: 33 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,41 +1,50 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim-amd64 as build-env
# Build stage
FROM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim-amd64 AS build-env
ARG TARGETPLATFORM
ARG BUILDPLATFORM

RUN apt-get update \
&& apt-get install -y ca-certificates curl gnupg \
&& mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-get install nodejs -y;
# Install Node.js
RUN apt-get update && apt-get install -y ca-certificates curl gnupg && \
mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \
apt-get install -y nodejs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

WORKDIR /App

COPY . ./

RUN echo "I am running on ${BUILDPLATFORM}"
RUN echo "building for ${TARGETPLATFORM}"
RUN export TARGETPLATFORM="${TARGETPLATFORM}"
RUN echo "Building on ${BUILDPLATFORM} for ${TARGETPLATFORM}"

RUN dotnet add src/ESPresense.Companion.csproj package MathNet.Numerics.Providers.MKL
RUN dotnet restore
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:8.0
# Runtime stage
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /App
EXPOSE 8267 8268
ENV ASPNETCORE_URLS "http://+:8267"
ENV OTA_UPDATE_PORT 8268
ENV CONFIG_DIR "/config/espresense"

RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \
apt-get update && apt-get install -y apt-transport-https gnupg software-properties-common wget && \
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB && \
apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB && \
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB && \
echo "deb https://apt.repos.intel.com/mkl all main" > /etc/apt/sources.list.d/intel-mkl.list && \
apt-get update && apt-get install -y intel-mkl-64bit-2020.0-088; \

ENV ASPNETCORE_URLS="http://+:8267" \
OTA_UPDATE_PORT=8268 \
CONFIG_DIR="/config/espresense"

# Install Intel oneAPI MKL for amd64 architecture
RUN if [ "$(uname -m)" = "x86_64" ]; then \
apt-get update && \
apt-get install -y --no-install-recommends \
gpg-agent \
wget && \
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | \
gpg --dearmor | tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null && \
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | \
tee /etc/apt/sources.list.d/oneAPI.list && \
apt-get update && \
apt-get install -y --no-install-recommends intel-oneapi-mkl && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*; \
fi

COPY --from=build-env /App/out .
Expand Down

0 comments on commit 1f36587

Please sign in to comment.