Skip to content

Instantly share code, notes, and snippets.

@denmerc
Created February 12, 2018 23:50
Show Gist options
  • Save denmerc/9d2111aaf9b0f15a2edee12dfd240288 to your computer and use it in GitHub Desktop.
Save denmerc/9d2111aaf9b0f15a2edee12dfd240288 to your computer and use it in GitHub Desktop.
.net core with Docker
nginx:
build: ./nginx
links:
- kestrel:kestrel
ports:
- "80:80"
kestrel:
build: .
ports:
- "5000"
# docker-compose up
# transfer
# docker images
# docker save -0 helloworld.tar helloworld
# -THEN-
# docker load -i helloworld.tar
# -OR-
# docker login
# docker build -t user/helloworld .
# docker push user/helloworld
# -THEN-
# docker pull user/helloworld
# "Dockerfile" to save w/o extension
FROM microsoft/dotnet:latest
COPY . /app
WORKDIR /
RUN dotnet restore
RUN dotnet build
EXPOSE 5000/tcp
ENV ASPNETCORE_URLS http://*:5000
ENTRYPOINT dotnet run
# build
# docker build -t hellowworld .
# test
# docker run -it -p 5000 helloworld
# run in prod manually
# docker run -d -p 5000:5000 helloworld
# docker ps
FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf
events { worker_connections 1024;}
http {
server {
listen 80;
location / {
proxy_pass http://kestrel:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'keep-alive';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment