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

publish in docker does not work #46

Closed
farshid3003 opened this issue Mar 6, 2019 · 9 comments
Closed

publish in docker does not work #46

farshid3003 opened this issue Mar 6, 2019 · 9 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@farshid3003
Copy link

The specified framework 'Microsoft.AspNetCore.App', version '2.2.0' was not found.

@Nordes
Copy link
Owner

Nordes commented Mar 6, 2019

If you run all locally, update dotnet coreon your pc and also clean the bin/obj folders.

@farshid3003
Copy link
Author

Just try to clone the code and run docker build.
It was working but it stop working several days ago as base docker image changed.

@farshid3003
Copy link
Author

you need yo use official docker image to solve this problem but it steel not easy. look at the end of this page
https://hackernoon.com/docker-writing-a-smaller-net-core-image-6710f4a1562a
it has a solution for 2.2

@Nordes
Copy link
Owner

Nordes commented Mar 7, 2019

Hi, thank you for raising the issue. I'll try to give a look tonight or over the weekend.

@Nordes Nordes added the bug Something isn't working label Mar 7, 2019
@Nordes
Copy link
Owner

Nordes commented Mar 9, 2019

Hi @farshid3003 , for info, I was already using the proper docker images (officials). They changed their URI recently. That being said, I was able to make it work again by adding the runtime in the build. The final image goes to 300mb :/. I am still looking if it could be possible to have a smaller image in the end.

Here's a functional dockerfile.

####################################################
# To build your own image: 
#    > docker build -t honosoft/vuejs-picnic:latest -t honosoft/vuejs-picnic:1.5.0 .
# To run your image once it's ready:
#    > docker run -d -p 8080:80 --name vuejs-picnic honosoft/vuejs-picnic
# To push the image into your docker repository:
#    > docker push honosoft/vuejs-picnic:latest
# If you wish to remove your dangling images, please do the following (not mandatory)
#    > docker rmi $(docker images -f “dangling=true” -q)
####################################################

# Build the container with Source code compiled
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-alpine3.8 as buildenv
WORKDIR /source
RUN apk add --update nodejs nodejs-npm
COPY *.csproj .
RUN dotnet restore
COPY . .
# Publishing will also restore (install) the npm packages.
RUN dotnet publish -c Release -o /app/ -r linux-musl-x64

# Stage 2 - Creating Image for compiled app
FROM mcr.microsoft.com/dotnet/core/runtime:2.2-alpine3.8 as baseimage
RUN addgroup -S coreApp && adduser -S -G coreApp coreApp
# RUN apk add --update nodejs nodejs-npm

# Define other environment variable if needed.
ENV ASPNETCORE_URLS=http://+:$port

WORKDIR /app
COPY --from=buildenv /app .
RUN chown -R coreApp:coreApp /app

# Replace the application name if required.
ENTRYPOINT ["dotnet", "VueJs.Picnic.CSharp.dll"]
EXPOSE $port

@farshid3003
Copy link
Author

yes you right, I think for the fix at least do something that works. don't worry about the image. image is not the container :)
so I think now you need to do something like this :

# Build runtime image
FROM microsoft/dotnet:2.2-aspnetcore-runtime As base
WORKDIR /app
EXPOSE 80

FROM microsoft/dotnet:2.2-sdk AS build-env
ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND teletype
RUN apt-get update \
    && apt-get -y upgrade \
    && apt-get -y dist-upgrade \
    && apt-get install -y gnupg \
    && apt-get install -y sudo \
    && curl -sL deb.nodesource.com/setup_10.x | sudo -E bash - \
    && apt-get install -y nodejs

# Copy csproj and restore as distinct layers
WORKDIR /src
COPY *.csproj ./
RUN dotnet restore 

# Copy everything else and build
COPY . .
WORKDIR "/src"
RUN dotnet build -c Release -o /app

# publish
FROM build-env AS publish
RUN dotnet publish -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "ProjectName.dll"]

this is working now.

@Nordes
Copy link
Owner

Nordes commented Mar 9, 2019

My example was working (just saying). I tried it locally before posting. I'll try with your proposition later.

@farshid3003
Copy link
Author

did you try to run the app after creating docker ?

@farshid3003
Copy link
Author

oh sorry I see you change the url yes that should work

Nordes pushed a commit that referenced this issue Mar 10, 2019
@Nordes Nordes closed this as completed Mar 30, 2019
@Nordes Nordes self-assigned this Apr 11, 2019
@Nordes Nordes added this to the 1.6.0 milestone Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants