Evolve
Evolve copied to clipboard
Are there any plans to create a docker image?
Hi are there any plans to create a docker image of evolve, this would be awesome when running Continues deployments?
This produces a bunch of Trim analysis
warnings, so I don't know if it actually works for all providers. I did some minimal tests against postgres and sqlite, YMMV.
FROM mcr.microsoft.com/dotnet/sdk:6.0.101-alpine3.14 as build
WORKDIR /build
COPY build/ build/
COPY src/ src/
RUN dotnet publish \
--configuration Release \
--framework net6.0 \
--runtime linux-x64 \
--self-contained \
-p:PublishSingleFile=true \
-p:PublishTrimmed=true \
-p:IncludeNativeLibrariesForSelfExtract=true \
src/Evolve.Tool/Evolve.Tool.csproj
RUN dotnet publish \
--configuration Release \
--framework net6.0 \
--runtime linux-musl-x64 \
--self-contained \
-p:PublishSingleFile=true \
-p:PublishTrimmed=true \
-p:IncludeNativeLibrariesForSelfExtract=true \
src/Evolve.Tool/Evolve.Tool.csproj
FROM debian:11.2-slim as evolve-bullseye
RUN apt-get update && apt-get install -y --no-install-recommends libicu67 && rm -rf /var/lib/apt/lists/*
COPY --from=build /build/src/Evolve.Tool/bin/Release/net6.0/linux-x64/publish/Evolve.Tool /usr/local/bin/evolve
ENTRYPOINT [ "evolve" ]
FROM alpine:3.15 as evolve-alpine
RUN apk add --update --no-cache libgcc libstdc++ icu
COPY --from=build /build/src/Evolve.Tool/bin/Release/net6.0/linux-musl-x64/publish/Evolve.Tool /usr/local/bin/evolve
ENTRYPOINT [ "evolve" ]
Build
docker build --target evolve-bullseye --tag evolve-bullseye .
docker build --target evolve-alpine --tag evolve-alpine .
Size
- Alpine: 28.2M Jan 7 12:11 /usr/local/bin/evolve
- Debian: 29M Jan 7 12:02 /usr/local/bin/evolve
SQLite sample
Set-StrictMode -Version Latest
$connection="Data Source=test.db;Version=3;"
docker run -it --rm `
--mount src="$(pwd)\db",target=/db,type=bind,readonly `
--mount src="$(pwd)\test.db",target=/test.db,type=bind `
evolve-alpine migrate sqlite -l db -c "$connection"
if (-not $?) { throw "Migrate failed" }
Your example is good, but I am not sure I want to build from source. It would be nice to replace the build segments with a simple dotnet tool install --global Evolve.Tool
. I am working on installing and using in CI as well. I will post any progress I make here.
This example could help also: https://github.com/lecaillon/Evolve/issues/253#issuecomment-1008131273
@ctoestreich Usually you want to avoid dotnet tool
in production containers because it depends on the .net sdk which is unnecessary bloat.
mcr.microsoft.com/dotnet/sdk 6.0.102-alpine3.14-amd64 9536e3d32191 4 days ago 578MB
The Dockerfile I posted above is sub-optimal:
- Remove
-p:IncludeNativeLibrariesForSelfExtract=true
as it doesn't matter in a container and probably affects startup performance. - Use https://hub.docker.com/_/microsoft-dotnet-runtime-deps/ as base which is specifically built for self-contained apps and avoids installing icu, see https://github.com/dotnet/dotnet-docker/blob/main/src/runtime-deps/3.1/alpine3.14/amd64/Dockerfile
@lecaillon I did setup a test repo (.net hello world) to experiment with docker and github actions here: https://github.com/peterhirn/testing-actions. I was thinking about creating a PR for evolve, but have some questions:
- are you ok with adding github actions or would you prefer to have everything in appveyor?
- what architectures would you like to support? In my sample repo I'm building
amd64
,arm/v7
,arm64
and-musl
variants, but I don't have a raspberry pi to test the output. ¯\_(ツ)_/¯
Hey @peterhirn What do you have in mind with those GitHub actions. Not sure to fully understand
Hi. I would add this action https://github.com/peterhirn/testing-actions/blob/main/.github/workflows/docker.yaml to build and push docker images on release. This requires two additional files: Dockerfile
and docker-bake.hcl
The action produces images like https://hub.docker.com/r/peter87623/testing-actions/tags
- alpine + bullseye
- three architectures mentioned above
- semver versions (
1
+1.0
+1.0.1
, or prereleases1.0.14-rc.1-alpine
)