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

Implement worker as a .NET Core app #18

Merged
merged 1 commit into from
Jun 13, 2016
Merged

Implement worker as a .NET Core app #18

merged 1 commit into from
Jun 13, 2016

Conversation

natemcmaster
Copy link

This replaces the Java worker with a .NET Core implementation using the RC2/Preview 1 image.

cc @SteveLasker @HaishiBai @Eilon @glennc

@Eilon
Copy link

Eilon commented Jun 12, 2016

My Java is a bit rusty, but the C# looks :shipit: to me.

@SteveLasker
Copy link

Yeah, Nate did a great job keeping the code concise. We're working on a proposal to clean up the dockerfile to have a more optimized image.

@friism
Copy link

friism commented Jun 12, 2016

@natemcmaster to reduce the final image size, instead of the default base image, I think you can get away with this:

FROM debian

# Work around https://github.com/dotnet/cli/issues/1582 until Docker releases a
# fix (https://github.com/docker/docker/issues/20818). This workaround allows
# the container to be run with the default seccomp Docker settings by avoiding
# the restart_syscall made by LTTng which causes a failed assertion.
ENV LTTNG_UST_REGISTER_TIMEOUT 0

# Install .NET CLI dependencies
RUN apt-get update \
     && apt-get install -y --no-install-recommends \
        ca-certificates \
#         clang-3.5 \
#         libc6 \
         libcurl3 \
#         libgcc1 \
         libicu52 \
#         liblttng-ust0 \
         libssl1.0.0 \
#         libstdc++6 \
#         libtinfo5 \
         libunwind8 \
#         libuuid1 \
#         zlib1g \
     && rm -rf /var/lib/apt/lists/*

# Install .NET Core SDK
ENV DOTNET_CORE_SDK_VERSION 1.0.0-preview1-002702
RUN apt-get update \
    && apt-get install -y --no-install-recommends curl\
    && curl -SL https://dotnetcli.blob.core.windows.net/dotnet/beta/Binaries/$DOTNET_CORE_SDK_VERSION/dotnet-dev-debian-x64.$DOTNET_CORE_SDK_VERSION.tar.gz --output dotnet.tar.gz \
    && apt-get purge -y --auto-remove curl \
    && rm -rf /var/lib/apt/lists/* \
    && mkdir -p /usr/share/dotnet \
    && tar -zxf dotnet.tar.gz -C /usr/share/dotnet \
    && rm dotnet.tar.gz \
    && ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet

@MichaelSimons

@friism
Copy link

friism commented Jun 12, 2016

@natemcmaster @SteveLasker so you'd have the above and then do what you're already doing in the same dockerfile

WORKDIR /app

ADD src/ /app/src/

RUN dotnet restore -v minimal src/ \
    && dotnet publish -c Release -o ./ src/Worker/ \
    && rm -rf src/ $HOME/.nuget/

CMD dotnet Worker.dll

the resulting image size is not too bad

@friism
Copy link

friism commented Jun 12, 2016

@bfirsh I've tested that this works end-to-end

@friism
Copy link

friism commented Jun 12, 2016

Full Dockerfile

FROM debian

# Work around https://github.com/dotnet/cli/issues/1582 until Docker releases a
# fix (https://github.com/docker/docker/issues/20818). This workaround allows
# the container to be run with the default seccomp Docker settings by avoiding
# the restart_syscall made by LTTng which causes a failed assertion.
ENV LTTNG_UST_REGISTER_TIMEOUT 0

# Install .NET CLI dependencies
RUN apt-get update \
     && apt-get install -y --no-install-recommends \
         ca-certificates \
         curl \
         libcurl3 \
         libicu52 \
         libssl1.0.0 \
         libunwind8 \
     && rm -rf /var/lib/apt/lists/*

# Install .NET Core SDK
ENV DOTNET_CORE_SDK_VERSION 1.0.0-preview1-002702
RUN apt-get update \
    && curl -SL https://dotnetcli.blob.core.windows.net/dotnet/beta/Binaries/$DOTNET_CORE_SDK_VERSION/dotnet-dev-debian-x64.$DOTNET_CORE_SDK_VERSION.tar.gz --output dotnet.tar.gz \
    && mkdir -p /usr/share/dotnet \
    && tar -zxf dotnet.tar.gz -C /usr/share/dotnet \
    && rm dotnet.tar.gz \
    && ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet

WORKDIR /app

ADD src/ /app/src/

RUN dotnet restore -v minimal src/ \
    && dotnet publish -c Release -o ./ src/Worker/ \
    && rm -rf src/ $HOME/.nuget/

CMD dotnet Worker.dll

@bfirsh
Copy link
Contributor

bfirsh commented Jun 13, 2016

LGTM

@bfirsh
Copy link
Contributor

bfirsh commented Jun 13, 2016

@friism I quite like the neatness of the smaller Dockerfile. What's the diff in image size? Maybe we can do this in a follow-up PR for the sake of getting this moving.

@bfirsh bfirsh merged commit f029fcc into dockersamples:master Jun 13, 2016
@natemcmaster natemcmaster deleted the dotnet branch June 13, 2016 01:44
@friism
Copy link

friism commented Jun 13, 2016

@bfirsh it's ~600MB

@SteveLasker
Copy link

The size is fairly important, at least until we get the build and run (fat/thin) containers worked out. Having an image half the size at ~300 mb is quite a difference.

From: Michael Friis [mailto:notifications@github.com]
Sent: Sunday, June 12, 2016 7:06 PM
To: docker/example-voting-app example-voting-app@noreply.github.com
Cc: Steve Lasker StevenLasker@Hotmail.com; Mention mention@noreply.github.com
Subject: Re: [docker/example-voting-app] Implement worker as a .NET Core app (#18)

@bfirsh https://github.com/bfirsh it's ~600MB


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub #18 (comment) , or mute the thread https://github.com/notifications/unsubscribe/AHSwlvAFHWnYnEqiPh0fRL7Gv1eybDNMks5qLLsQgaJpZM4IzpfV .

@natemcmaster
Copy link
Author

FWIW, we intend to create an Alpine-based version of the dotnet image for the next release. This should cut much of the fat that comes from the jessie base image. Cref dotnet/dotnet-docker#22 cc @dleeapho

Olivety pushed a commit to Olivety/example-voting-app that referenced this pull request Nov 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants