Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are there any plans to create a docker image? #248

Open
AnderssonPeter opened this issue Dec 6, 2021 · 6 comments
Open

Are there any plans to create a docker image? #248

AnderssonPeter opened this issue Dec 6, 2021 · 6 comments
Labels

Comments

@AnderssonPeter
Copy link

Hi are there any plans to create a docker image of evolve, this would be awesome when running Continues deployments?

@peterhirn
Copy link

peterhirn commented Jan 7, 2022

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" }

@ctoestreich
Copy link

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.

@lecaillon
Copy link
Owner

This example could help also: #253 (comment)

@peterhirn
Copy link

@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:

@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. ¯\_(ツ)_/¯

@lecaillon
Copy link
Owner

Hey @peterhirn
What do you have in mind with those GitHub actions. Not sure to fully understand

@peterhirn
Copy link

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 prereleases 1.0.14-rc.1-alpine)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants