Skip to content

Commit

Permalink
Switch to Azure Linux (#1418)
Browse files Browse the repository at this point in the history
* Switch to Azure Linux base image (#1410)

- Reduces the overall final image size by using Azure Linux
- Offers maximum compatibility with Azure infrastructure
- Supported by Microsoft

* Add missing software packages

* Ensure user can access necessary files

* Remove dependency on existing layer

* Removed unused prose
  • Loading branch information
DrizzlyOwl authored Nov 25, 2024
1 parent 4cd1ea8 commit 0db6322
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
32 changes: 18 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# Stage 1
ARG ASPNET_SDK_TAG=8.0
ARG ASPNET_IMAGE_TAG=8.0-bookworm-slim
ARG NODEJS_IMAGE_TAG=20.17-bullseye
# Set the major version of dotnet
ARG DOTNET_VERSION=8.0
# Set the major version of nodejs
ARG NODEJS_VERSION_MAJOR=22

ARG COMMIT_SHA=not-set

# ==============================================
# Base SDK
# ==============================================
FROM "mcr.microsoft.com/dotnet/sdk:${ASPNET_SDK_TAG}" AS builder
FROM "mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-azurelinux3.0" AS builder
ARG COMMIT_SHA
WORKDIR /build
RUN ["tdnf", "update"]
RUN ["tdnf", "install", "-y", "jq"]
RUN ["tdnf", "clean", "all"]
COPY ConcernsCaseWork/. .
RUN dotnet restore ConcernsCaseWork
RUN dotnet build ConcernsCaseWork "/p:customBuildMessage=Manifest commit SHA... ${COMMIT_SHA};" -c Release
Expand All @@ -34,31 +38,31 @@ RUN dotnet ef migrations bundle -r linux-x64 --configuration Release -p Concerns
# ==============================================
# Entity Framework: Migration Runner
# ==============================================
FROM "mcr.microsoft.com/dotnet/aspnet:${ASPNET_IMAGE_TAG}" AS initcontainer
FROM "mcr.microsoft.com/dotnet/aspnet:${DOTNET_VERSION}-azurelinux3.0" AS initcontainer
WORKDIR /sql
COPY --from=efbuilder /sql /sql
COPY --from=builder /app/appsettings* /ConcernsCaseWork/
RUN chown "$APP_UID" "/sql" -R
RUN chown "$APP_UID" "/ConcernsCaseWork" -R
USER $APP_UID

# ==============================================
# Front End Builder
# ==============================================
FROM node:${NODEJS_IMAGE_TAG} AS frontend
COPY --from=builder /app/wwwroot /app/wwwroot
FROM "node:${NODEJS_VERSION_MAJOR}-bullseye-slim" AS frontend
COPY ConcernsCaseWork/ConcernsCaseWork/wwwroot /app/wwwroot
WORKDIR /app/wwwroot
RUN npm install
RUN npm run build

# ==============================================
# Application
# ==============================================
FROM "mcr.microsoft.com/dotnet/aspnet:${ASPNET_IMAGE_TAG}" AS final
LABEL org.opencontainers.image.source=https://github.com/DFE-Digital/record-concerns-support-trusts
ARG COMMIT_SHA
FROM "mcr.microsoft.com/dotnet/aspnet:${DOTNET_VERSION}-azurelinux3.0" AS final
LABEL org.opencontainers.image.source="https://github.com/DFE-Digital/record-concerns-support-trusts"
COPY --from=builder /app /app
COPY --from=frontend /app/wwwroot /app/wwwroot
COPY ./script/web-docker-entrypoint.sh /app/docker-entrypoint.sh
WORKDIR /app
RUN chown -R app:app /app
RUN chmod +x ./docker-entrypoint.sh
USER app
EXPOSE 8080/tcp
USER $APP_UID
2 changes: 0 additions & 2 deletions script/set-appsettings-release-tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
set -e
set -o pipefail

apt-get update && apt-get install jq -y

RELEASE_TAG="$1"

APP_SETTINGS_FILES=(
Expand Down

0 comments on commit 0db6322

Please sign in to comment.