Skip to content
Draft
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
16 changes: 14 additions & 2 deletions .github/workflows/build-api-lambda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,21 @@ jobs:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.ref }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Amazon Linux 2023 build
run: |
docker build . -t api-lambda:latest -f src/api/Elastic.Documentation.Api.Lambda/Dockerfile
uses: docker/build-push-action@v6
with:
context: .
file: src/api/Elastic.Documentation.Api.Lambda/Dockerfile
push: false
load: true
tags: api-lambda:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Get bootstrap binary
run: |
docker cp $(docker create --name tc api-lambda:latest):/app/.artifacts/publish ./.artifacts && docker rm tc
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/build-link-index-updater-lambda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,21 @@ jobs:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.ref }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Amazon Linux 2023 build
run: |
docker build . -t publish-links-index:latest -f src/infra/docs-lambda-index-publisher/lambda.DockerFile
uses: docker/build-push-action@v6
with:
context: .
file: src/infra/docs-lambda-index-publisher/lambda.DockerFile
push: false
load: true
tags: publish-links-index:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Get bootstrap binary
run: |
docker cp $(docker create --name tc publish-links-index:latest):/app/.artifacts/publish ./.artifacts && docker rm tc
Expand Down
56 changes: 30 additions & 26 deletions src/api/Elastic.Documentation.Api.Lambda/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,37 @@ ARG TARGETOS

WORKDIR /app

RUN rpm --import https://packages.microsoft.com/keys/microsoft.asc

#RUN curl -o /etc/yum.repos.d/microsoft-prod.repo https://packages.microsoft.com/config/fedora/41/prod.repo

RUN dnf update -y
#RUN dnf install -y dotnet-sdk-10.0
RUN dnf install -y npm
RUN dnf install -y git
RUN dnf install -y clang

## temporary see: https://github.com/amazonlinux/amazon-linux-2023/issues/1025
RUN dnf install -y tar
RUN dnf install -y findutils
RUN curl -L https://dot.net/v1/dotnet-install.sh -o dotnet-install.sh
RUN chmod +x ./dotnet-install.sh
RUN ./dotnet-install.sh
ENV PATH="$PATH:/root/.dotnet"
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
# /end temporary
# Set environment variables early (no layer cost)
ENV PATH="$PATH:/root/.dotnet" \
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 \
DOTNET_NOLOGO=true \
DOTNET_CLI_TELEMETRY_OPTOUT=true

# Install all system dependencies in a single layer
RUN rpm --import https://packages.microsoft.com/keys/microsoft.asc && \
dnf update -y && \
dnf install -y npm git clang tar findutils && \
dnf clean all

# Install .NET SDK based on global.json version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should leave in the comment that this might be temporary:

amazonlinux/amazon-linux-2023#1025

COPY global.json .
RUN curl -L https://dot.net/v1/dotnet-install.sh -o dotnet-install.sh && \
chmod +x ./dotnet-install.sh && \
./dotnet-install.sh --jsonfile ./global.json && \
rm dotnet-install.sh

# Copy solution/project files for dependency restoration
# .dockerignore already excludes bin/, obj/, node_modules/, etc.
# This includes all .csproj, .fsproj, .props, and source files
# dotnet restore only reads project files, so having source files here is fine
COPY . .

ENV DOTNET_NOLOGO=true \
DOTNET_CLI_TELEMETRY_OPTOUT=true

RUN arch=$TARGETARCH \
&& if [ "$arch" = "amd64" ]; then arch="x64"; fi \
&& echo $TARGETOS-$arch > /tmp/rid
# Restore dependencies
# Note: We use cache mount for NuGet packages, but don't use --no-restore in publish
# because Native AOT compilation needs the full MSBuild evaluation
RUN --mount=type=cache,target=/root/.nuget/packages \
dotnet restore src/api/Elastic.Documentation.Api.Lambda -r linux-x64

RUN dotnet publish src/api/Elastic.Documentation.Api.Lambda -r linux-x64 -c Release
# Build and publish (Native AOT requires full evaluation, so we don't use --no-restore)
RUN --mount=type=cache,target=/root/.nuget/packages \
dotnet publish src/api/Elastic.Documentation.Api.Lambda -r linux-x64 -c Release
56 changes: 30 additions & 26 deletions src/infra/docs-lambda-index-publisher/lambda.DockerFile
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,37 @@ ARG TARGETOS

WORKDIR /app

RUN rpm --import https://packages.microsoft.com/keys/microsoft.asc

#RUN curl -o /etc/yum.repos.d/microsoft-prod.repo https://packages.microsoft.com/config/fedora/41/prod.repo

RUN dnf update -y
#RUN dnf install -y dotnet-sdk-10.0
RUN dnf install -y npm
RUN dnf install -y git
RUN dnf install -y clang

## temporary see: https://github.com/amazonlinux/amazon-linux-2023/issues/1025
RUN dnf install -y tar
RUN dnf install -y findutils
RUN curl -L https://dot.net/v1/dotnet-install.sh -o dotnet-install.sh
RUN chmod +x ./dotnet-install.sh
RUN ./dotnet-install.sh
ENV PATH="$PATH:/root/.dotnet"
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
# /end temporary
# Set environment variables early (no layer cost)
ENV PATH="$PATH:/root/.dotnet" \
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 \
DOTNET_NOLOGO=true \
DOTNET_CLI_TELEMETRY_OPTOUT=true

# Install all system dependencies in a single layer
RUN rpm --import https://packages.microsoft.com/keys/microsoft.asc && \
dnf update -y && \
dnf install -y npm git clang tar findutils && \
dnf clean all

# Install .NET SDK based on global.json version
COPY global.json .
RUN curl -L https://dot.net/v1/dotnet-install.sh -o dotnet-install.sh && \
chmod +x ./dotnet-install.sh && \
./dotnet-install.sh --jsonfile ./global.json && \
rm dotnet-install.sh

# Copy solution/project files for dependency restoration
# .dockerignore already excludes bin/, obj/, node_modules/, etc.
# This includes all .csproj, .fsproj, .props, and source files
# dotnet restore only reads project files, so having source files here is fine
COPY . .

ENV DOTNET_NOLOGO=true \
DOTNET_CLI_TELEMETRY_OPTOUT=true

RUN arch=$TARGETARCH \
&& if [ "$arch" = "amd64" ]; then arch="x64"; fi \
&& echo $TARGETOS-$arch > /tmp/rid
# Restore dependencies
# Note: We use cache mount for NuGet packages, but don't use --no-restore in publish
# because Native AOT compilation needs the full MSBuild evaluation
RUN --mount=type=cache,target=/root/.nuget/packages \
dotnet restore src/infra/docs-lambda-index-publisher -r linux-x64

RUN dotnet publish src/infra/docs-lambda-index-publisher -r linux-x64 -c Release
# Build and publish (Native AOT requires full evaluation, so we don't use --no-restore)
RUN --mount=type=cache,target=/root/.nuget/packages \
dotnet publish src/infra/docs-lambda-index-publisher -r linux-x64 -c Release
Loading