forked from RickStrahl/AlbumViewerVNext
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docker support - docker for Web app and docker-compose for nginx …
…and aspnet support.
- Loading branch information
1 parent
34175a0
commit 0f40953
Showing
9 changed files
with
249 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
GET http://localhost:8081/index.html HTTP/1.1 | ||
Accept-Encoding: gzip,deflate | ||
|
||
------------------------------------------------------------------ | ||
|
||
GET http://localhost:8081/api/artist/1 HTTP/1.1 | ||
Accept-Encoding: gzip,deflate | ||
|
||
------------------------------------------------------------------ | ||
|
||
GET http://localhost:8081/api/helloworld HTTP/1.1 | ||
Accept-Encoding: gzip,deflate | ||
|
||
------------------------------------------------------------------ | ||
|
||
|
||
----- Start WebSurge Options ----- | ||
|
||
{ | ||
"NoProgressEvents": true, | ||
"DelayTimeMs": -1, | ||
"NoContentDecompression": false, | ||
"CaptureMinimalResponseData": false, | ||
"MaxResponseSize": 0, | ||
"ReplaceCookieValue": null, | ||
"ReplaceAuthorization": null, | ||
"ReplaceQueryStringValuePairs": null, | ||
"ReplaceDomain": "", | ||
"Username": null, | ||
"Password": null, | ||
"RandomizeRequests": false, | ||
"RequestTimeoutMs": 15000, | ||
"WarmupSeconds": 2, | ||
"ReloadTemplates": false, | ||
"FormattedPreviewTheme": "visualstudio", | ||
"LastThreads": 8, | ||
"IgnoreCertificateErrors": false, | ||
"LastSecondsToRun": 30 | ||
} | ||
|
||
// This file was generated by West Wind WebSurge | ||
// Get your free copy at http://websurge.west-wind.com | ||
// to easily test or load test the requests in this file. | ||
|
||
----- End WebSurge Options ----- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Run docker-compose build | ||
# Run docker-compose up | ||
# Live long and prosper | ||
|
||
version: '2' | ||
|
||
services: | ||
|
||
nginx: | ||
container_name: nginxalbumviewer | ||
image: nginxalbumviewer | ||
build: | ||
context: ./nginx | ||
dockerfile: Dockerfile | ||
# volumes:. | ||
# - ./dist:/usr/share/nginx/html | ||
ports: | ||
- "8081:80" | ||
# - "443:443" | ||
networks: | ||
- app-network | ||
|
||
aspnet: | ||
container_name: 'westwindalbumviewer' | ||
image: 'westwind/albumviewer:albumviewer' | ||
build: | ||
context: ./src/AlbumViewerNetCore | ||
dockerfile: ./Dockerfile | ||
# volumes: | ||
# - ./src/AlbumViewerNetCore:/var/www/albumviewer | ||
ports: | ||
- "5000:5000" | ||
networks: | ||
- app-network | ||
|
||
networks: | ||
app-network: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# dotnet publish -c Release | ||
# robocopy ./src/albumviewernetcore/wwwroot ./nginx/wwwroot /MIR | ||
|
||
docker rm westwind/albumviewer -f | ||
docker rm nginxalbumviewer -f | ||
|
||
docker-compose build | ||
|
||
# docker-compose up | ||
# docker-compose down | ||
|
||
# docker network inspect albumviewervnext_app-network |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Shut down running container | ||
docker rm nginxalbumviewer -f | ||
|
||
# Have to copy files from wwwroot in order to be part of context | ||
robocopy ./src/albumviewernetcore/wwwroot ./nginx/wwwroot /MIR | ||
|
||
# Build the image | ||
docker build -t nginxalbumviewer:nginxalbumviewer ./nginx | ||
|
||
# Run it | ||
docker run -p 5003:80 --name nginxalbumviewer nginxalbumviewer:nginxalbumviewer | ||
|
||
|
||
#docker stop nginxalbumviewer | ||
#docker rm nginxalbumviewer | ||
|
||
# docker exec -it nginxalbumviewer /bin/bash | ||
|
||
# # if above doesn't work | ||
# docker exec -it nginxalbumviewer /bin/sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM nginx:alpine | ||
|
||
MAINTAINER Rick Strahl | ||
|
||
# Copy custom nginx config | ||
COPY ./nginx.conf /etc/nginx/nginx.conf | ||
COPY ./wwwroot /usr/share/nginx/html | ||
|
||
EXPOSE 80 443 | ||
|
||
ENTRYPOINT ["nginx"] | ||
CMD ["-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
worker_processes 4; | ||
|
||
events { worker_connections 1024; } | ||
|
||
http { | ||
ssl_session_cache shared:SSL:10m; | ||
ssl_session_timeout 30m; | ||
|
||
#See http://blog.argteam.com/coding/hardening-node-js-for-production-part-2-using-nginx-to-avoid-node-js-load | ||
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m; | ||
proxy_temp_path /var/tmp; | ||
include mime.types; | ||
default_type application/octet-stream; | ||
sendfile on; | ||
keepalive_timeout 65; | ||
|
||
gzip on; | ||
gzip_comp_level 6; | ||
gzip_vary on; | ||
gzip_min_length 1000; | ||
gzip_proxied any; | ||
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; | ||
gzip_buffers 16 8k; | ||
|
||
|
||
server { | ||
listen 80; | ||
|
||
# Server name. You need a DNS record (or add this hostname to your hosts file) | ||
#server_name core-app.local; | ||
|
||
server_name localhost; | ||
|
||
location / { | ||
root /usr/share/nginx/html; | ||
index index.html; | ||
expires -1; | ||
add_header web-server "nginx"; | ||
add_header Pragma "no-cache"; | ||
add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"; | ||
try_files $uri$args $uri$args/ $uri $uri/ /index.html =404; | ||
} | ||
|
||
location /api { | ||
proxy_pass http://dotnet; | ||
add_header web-server "kestrel"; | ||
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; | ||
} | ||
} | ||
|
||
upstream dotnet { | ||
zone dotnet 64k; | ||
server westwindalbumviewer:5000; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM microsoft/dotnet:1.1.1-sdk | ||
|
||
MAINTAINER Rick Strahl | ||
|
||
ENV ASPNETCORE_URLS=http://*:5000 | ||
ENV ASPNETCORE_ENVIRONMENT=Development | ||
|
||
# | ||
# Allow 1433 for SQL Server Access | ||
EXPOSE 1433 | ||
|
||
# copy publish folder contents to web root | ||
COPY ./bin/Release/netcoreapp1.1/publish /var/www/albumviewer | ||
|
||
# Explicitly build app. Problems with this approach as multiple projects | ||
#COPY . /var/www/albumviewer | ||
#COPY ../AlbumViewerBusiness /var/www/AlbumViewerBusiness | ||
|
||
WORKDIR /var/www/albumviewer | ||
|
||
#CMD ["/bin/sh", "-c", "dotnet restore && dotnet publish -c Release && cd ./bin/Release/netcoreapp1.1/publish && dotnet AlbumViewerNetCore.dll"] | ||
|
||
# Run out of Publish Folder | ||
CMD ["/bin/sh", "-c", "dotnet 'AlbumViewerNetCore.dll'"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# publish the application first | ||
dotnet publish -c Release | ||
|
||
# clean up old image and any containers (running or not) | ||
docker stop albumviewer | ||
docker rm albumviewer -f | ||
docker rmi westwind/albumviewer:albumviewer | ||
|
||
# create new image | ||
docker build -t westwind/albumviewer:albumviewer . | ||
|
||
# immediately start running the container in the background (-d) | ||
docker run -p 5004:5000 --name albumviewer westwind/albumviewer:albumviewer | ||
|
||
#docker stop albumviewer | ||
#docker rm albumviewer | ||
|
||
# docker exec -it albumviewer /bin/bash | ||
|
||
# # if above doesn't work | ||
# docker exec -it albumviewer /bin/sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
dotnet publish -c Release | ||
|
||
docker stop albumviewer | ||
docker rm albumviewer -f | ||
|
||
docker build -t westwind/albumviewer:albumviewer . | ||
|
||
docker run -d -p 5004:5000 --name albumviewer westwind/albumviewer:albumviewer | ||
|
||
#docker stop albumviewer | ||
#docker rm albumviewer | ||
|
||
# docker exec -it albumviewer /bin/bash | ||
|
||
# # if above doesn't work | ||
# docker exec -it albumviewer /bin/sh |