allReady icon indicating copy to clipboard operation
allReady copied to clipboard

Added docker support for debugging

Open mk0sojo opened this issue 8 years ago • 10 comments

For #2247

First shot at debugging the web app in a docker containers (one for the app and one for SQL server). This is the steps to try this out:

  1. Download and install Git, Docker and Editor or IDE (e.g. VS Code).
  2. Make sure Docker is set up to use Linux containers (if running on Windows) and got 4 GB memory or more allocated to run SQL Server (set in Preferences).
  3. Fork and clone repository
  4. Open terminal or Powershell
  5. Cd to the AlreadyApp directory and type “docker-compose up”. This will take some time the first time it runs as it will download ASP.Net core and SQL Server base images.
  6. Open a browser and navigate to localhost:8000

The main remaining issue is after changing anything in the project the whole project is restored, build and nom packages are installed (even if it is just a change to a HTML file)

Will try to solve it, but please let me know what you think so far. I have only tried it on a Mac so far but it “should” work on Windows as well.

mk0sojo avatar Jan 27 '18 21:01 mk0sojo

@mk0sojo That's awesome work. Hopefully this will make it much easier for people to get started. Have you tested debugging with VS code or Visual Studio?

jonparker avatar Jan 29 '18 13:01 jonparker

@jonparker Still needs to add a better debugging experience and need to speed up the restore / build process a bit. Will look into it a bit more.

mk0sojo avatar Jan 30 '18 06:01 mk0sojo

@jonparker @MisterJames Added support for debugging in VS Code and tried to speed up the build time a bit. To try:

  1. Clone repo
  2. In AllreadyApp folder run docker-compose up
  3. When done open another terminal and type docker ps. allreadyweb and allreadysqlserver should be running
  4. Open the AllreadyApp folder in VS Code. Go to the debug tab and press play (or just F5). Brake points should now work

image

The only (known) limitation is that it is not possible to edit an HTML or CSS file without rebuilding.

Let me know what you think.

mk0sojo avatar Feb 03 '18 15:02 mk0sojo

That's great. Have you heard of docker-sync? It allows for you to build within the container while having the files checked out on the host.

http://docker-sync.io

jonparker avatar Feb 03 '18 15:02 jonparker

It looks like it could be usefull, my only concern is that it looks a bit complicated to install (on windows in particular https://github.com/EugenMayer/docker-sync/wiki/docker-sync-on-Windows). I'm not sure if that is any better than the installation instructions we currently have running everything locally? On our codathons, is there any particular step that users find difficult or is it just the number of steps?

mk0sojo avatar Feb 04 '18 14:02 mk0sojo

@mk0sojo I tested this on Windows and there was an issue with the line endings in AllReadyApp/entrypoint.sh:

allreadyweb | ../../entrypoint.sh: line 2: $'\r': command not found 
: invalid option/../entrypoint.sh: line 3: set: - 
allreadyweb | set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...] 
allreadyweb | ../../entrypoint.sh: line 12: syntax error: unexpected end of file 
allreadyweb exited with code 2 

The cause was the bash script being checked with the Windows line-ending, \r\n. When run on Linux inside the Docker container, the \r breaks the script.

The issue is described is more detail here: https://techblog.dorogin.com/case-of-windows-line-ending-in-bash-script-7236f056abe

The solution is to configure .gitattributes to convert bash script line endings to LF on checkout so it will retain the Unix line-endings regardless of operating system.

I've made this change to a clone of your branch here: https://github.com/tony-ho/allReady/tree/issue-branch-2247

I also rewrote the Docker connection string logic. Instead of using the ALLREADY_DOCKER_DEBUG environment variable to conditionally set Docker-specific connection strings, the connection strings can be passed as environment variables via docker-compose.yml. These will override the values in appSettings.json.

Let me know if and how you want to merge these changes.

tony-ho avatar Feb 20 '18 13:02 tony-ho

@tony-ho Thanks for the feedback and testing it on Windows. The changes to the connection string logic looks great as well. Let me know if you have any more feedback.

mk0sojo avatar Feb 21 '18 08:02 mk0sojo

This is great stuff.

I'd like to merge this in, do we need another commit @mk0sojo for those line endings?

MisterJames avatar Feb 21 '18 21:02 MisterJames

@MisterJames I have added @tony-ho changes to the pull request so it should be ok to merge now.

mk0sojo avatar Feb 22 '18 21:02 mk0sojo

@MisterJames Is there anything else missing here before it can be merged?

mk0sojo avatar Mar 11 '18 12:03 mk0sojo