Skip to content

Instantly share code, notes, and snippets.

@perosb
Created June 28, 2021 07:39
Show Gist options
  • Save perosb/f99370d2c0a7e5e1bef60b712cdece20 to your computer and use it in GitHub Desktop.
Save perosb/f99370d2c0a7e5e1bef60b712cdece20 to your computer and use it in GitHub Desktop.
Sitecore 10.1 and kubernetes container for serialization
# escape=`
FROM mcr.microsoft.com/dotnet/sdk:3.1 as prep
ENV SITECORE_PUBLIC_NUGET_FEED=https://sitecore.myget.org/F/sc-packages/api/v3/index.json
ENV CM_HOST=
ENV ID_HOST=
ENV CLIENT=
ENV SECRET=
ENV ENVIRONMENT=dev
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
USER ContainerAdministrator
WORKDIR /content/
COPY .config .
COPY sitecore.json .
COPY docker/build/content/start.ps1 /
RUN `
dotnet nuget add source -n Sitecore $env:SITECORE_PUBLIC_NUGET_FEED; `
dotnet tool restore --add-source=$env:SITECORE_PUBLIC_NUGET_FEED; `
dotnet sitecore plugin add -n Sitecore.DevEx.Extensibility.Serialization; `
dotnet sitecore plugin add -n Sitecore.DevEx.Extensibility.Publishing;
FROM prep as create
COPY src/ /content/src/
RUN dotnet sitecore ser pkg create -o content --overwrite
FROM prep as final
COPY --from=create /content/content.itempackage .
ENTRYPOINT "pwsh" "-File" "/start.ps1"
dotnet sitecore login -n $env:ENVIRONMENT --client-credentials true --auth "$env:ID_HOST" --cm "$env:CM_HOST" --allow-write true --client-id "$env:CLIENT" --client-secret "$env:SECRET"
if ($LASTEXITCODE -ne 0) {
Write-Error "Unable to log into Sitecore, did the Sitecore environment start correctly? See logs above."
}
if ($null -eq $env:EXCLUDE -or $env:EXCLUDE -eq "") {
write-host "Pushing content"
dotnet sitecore ser pkg install -f content.itempackage -n $env:ENVIRONMENT
} else {
write-host "Pushing content with $env:EXCLUDE excluded"
dotnet sitecore ser pkg install -f content.itempackage -n $env:ENVIRONMENT --exclude "$env:EXCLUDE"
}
dotnet sitecore publish --verbose -n $env:ENVIRONMENT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment