-
Notifications
You must be signed in to change notification settings - Fork 629
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
Added docker support for debugging #2298
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Set default behavior to automatically normalize line endings. | ||
* text=auto | ||
|
||
# Always convert bash script line endings to LF on checkout. | ||
*.sh text eol=lf |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.dockerignore | ||
.env | ||
.git | ||
.gitignore | ||
.vs | ||
.vscode | ||
docker-compose.yml | ||
docker-compose.*.yml | ||
*/bin | ||
*/obj | ||
!obj/Docker/publish/* | ||
!obj/Docker/empty/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Debug in Docker", | ||
"type": "coreclr", | ||
"request": "launch", | ||
"program": "/app/Web-App/AllReady/bin/Debug/netcoreapp2.0/AllReady.dll", | ||
"cwd": "/app/Web-App/AllReady", | ||
"sourceFileMap": { | ||
"/app": "${workspaceRoot}" | ||
}, | ||
"pipeTransport": { | ||
"pipeProgram": "docker", | ||
"pipeCwd": "${workspaceRoot}", | ||
"pipeArgs": [ | ||
"exec -i allreadyweb" | ||
], | ||
"quoteArgs": false, | ||
"debuggerPath": "/root/vsdbg/vsdbg" | ||
} | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
FROM microsoft/aspnetcore-build:2.0 | ||
|
||
#Install debugger | ||
RUN apt-get update | ||
RUN apt-get install curl -y unzip | ||
RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg | ||
|
||
# Install npm packages | ||
WORKDIR /app/Web-App/AllReady | ||
COPY Web-App/AllReady/package.json . | ||
COPY Web-App/AllReady/package-lock.json . | ||
RUN ["npm", "install"] | ||
|
||
# Run dotnet restore | ||
WORKDIR /app | ||
COPY *.sln ./ | ||
COPY Web-App/AllReady/AllReady.csproj Web-App/AllReady/ | ||
COPY AllReady.Core/AllReady.Core.csproj AllReady.Core/ | ||
RUN dotnet restore AllReadyWebOnly.sln | ||
COPY . . | ||
WORKDIR /app/Web-App/AllReady | ||
|
||
# Build project | ||
RUN ["dotnet","build"] | ||
|
||
# Run gulp tasks | ||
RUN gulp clean && gulp min | ||
EXPOSE 80/tcp | ||
RUN chmod +x ../../entrypoint.sh | ||
CMD /bin/bash ../../entrypoint.sh | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM microsoft/aspnetcore-build:2.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mk0sojo This whole dockerfile seems to do nothing more than just install the vs debugger and then on startup just keep the process running. What purpose does it serve? |
||
RUN mkdir app | ||
|
||
#Install debugger | ||
RUN apt-get update | ||
RUN apt-get install curl -y unzip | ||
RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg | ||
|
||
EXPOSE 80/tcp | ||
|
||
#Keep the debugger container on | ||
ENTRYPOINT ["tail", "-f", "/dev/null"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,7 +169,7 @@ public IServiceProvider ConfigureServices(IServiceCollection services) | |
|
||
//Hangfire | ||
services.AddHangfire(configuration => configuration.UseSqlServerStorage(Configuration["Data:HangfireConnection:ConnectionString"])); | ||
|
||
services.AddScoped<IAllReadyUserManager, AllReadyUserManager>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file seems to only have whitespace changes - perhaps it could be excluded/rolled-back from the PR (i.e. |
||
services.AddScoped<IUserAuthorizationService, UserAuthorizationService>(); | ||
services.AddScoped<IAuthorizableEventBuilder, AuthorizableEventBuilder>(); | ||
|
@@ -184,7 +184,6 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, AllReady | |
{ | ||
// Put first to avoid issues with OPTIONS when calling from Angular/Browser. | ||
app.UseCors("allReady"); | ||
|
||
app.UseSession(); | ||
|
||
// Add the following to the request pipeline only in development environment. | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,28 @@ | ||||||
version: "3" | ||||||
services: | ||||||
web: | ||||||
build: | ||||||
context: . | ||||||
dockerfile: Web-App/AllReady/Dockerfile | ||||||
container_name: allreadyweb | ||||||
environment: | ||||||
ASPNETCORE_ENVIRONMENT: Development | ||||||
Data__DefaultConnection__ConnectionString: "Server=db,1433;Initial Catalog=master;Persist Security Info=False;User ID=sa;Password=yourStrong(!)Password;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;" | ||||||
Data__HangfireConnection__ConnectionString: "Server=db,1433;Initial Catalog=master;Persist Security Info=False;User ID=sa;Password=yourStrong(!)Password;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;" | ||||||
ports: | ||||||
- "8000:80" | ||||||
depends_on: | ||||||
- db | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the db container takes a bit of time to spin up, I'd suggest adding restart: on-failure So that docker could retry starting the app if the db is not yet up and running. |
||||||
db: | ||||||
image: "microsoft/mssql-server-linux:2017-CU3" | ||||||
container_name: allreadysqlserver | ||||||
volumes: | ||||||
- sql-server-data:/var/opt/mssql | ||||||
ports: | ||||||
- "1433:1433" | ||||||
environment: | ||||||
SA_PASSWORD: "yourStrong(!)Password" | ||||||
ACCEPT_EULA: "Y" | ||||||
|
||||||
volumes: | ||||||
sql-server-data: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also I could not see where is the logic that actually creates the database table Lines 46 to 47 in 37833fc
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
run_cmd="tail -f /dev/null" | ||
until dotnet ef database update; do | ||
>&2 echo "SQL Server is starting up" | ||
sleep 1 | ||
done | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file seems to only run the migration and does not actually start the app. i.e. |
||
>&2 echo "App and SQL Server is running" | ||
exec $run_cmd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having a whole separate file (
entrypoint.sh
) I believe we could just simply chain the migration and the app start. That we we can drop the .sh file and also the end-of-line issues discussed in the PR comments.