-
Notifications
You must be signed in to change notification settings - Fork 483
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
Make the demo server be a single docker image #450
Conversation
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.
Nice, just some comments for clarity & cleaning up.
I also wonder if there's any reason to keep the old version around, and have this be a new distro? i.e. Would integrators ever still want to run frontend and backend in different places?
group = 'docker' | ||
dependsOn buildDemoServerImage, buildClientImage | ||
dependsOn buildDemoImage | ||
} | ||
|
||
task installToolsAndDockerize { | ||
description = 'Installs required build tools and builds the Client and API Server Docker images' |
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.
should this desc be updated? since client and backend are now in the same image
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.
Done.
defaultCommand("java", "-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005", "-jar", "/app/demo-server-all.jar") | ||
// nginx configuration | ||
runCommand("apt-get update") | ||
runCommand("apt-get -y install nginx") |
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.
can nginx be installed from an image, similar to how we do the java image? then you can define version number too
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.
No I don't think so. A docker image can only have one base, so we have to either start from the nginx base or the java base, and install the other. I think we might be able to use docker compose to solve this problem, but that adds another dependency, so while maybe we will switch to that latter I didn't want to do that now.
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.
Ack
copyFile("build/webapp/test-keys/server.key", "/etc/ssl") | ||
|
||
// Install supervisor to allow mutliple processes to run | ||
runCommand("apt-get install -y supervisor") |
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.
same here, can supervisor come from an image?
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.
I don't think so, for the same reasons.
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.
Ack
//defaultCommand("java", "-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005", "-jar", "/app/demo-server-all.jar") | ||
copyFile("src/config/demo/supervisord.conf", "/etc/supervisor/conf.d/supervisord.conf") | ||
|
||
defaultCommand("/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf") | ||
// Read in secrets and set them as environment variables. |
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.
TODO for issue #449 ?
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.
Done.
// create the user nginx runs as, matches user in nginx.config | ||
runCommand("adduser --disabled-password nginx") | ||
|
||
copyFile("src/config/client/nginx.conf", "/etc/nginx") |
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.
can nginx work be moved to a separate task this dependsOn?
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.
I don't think so no, this is to compose the docker file, so I think it all needs to be together.
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.
ah, misread this, copyFile is a Dockerfile directive right? forgot how that worked and read it as a scripted copy
maybe for clarity, document that these commands are all generating Dockerfile directives
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.
I think that might be overly commenting the file.
I started to try it out, but then it seemed wierd we didn't explain that runCommand was just a docker command as well.
|
||
//defaultCommand("java", "-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005", "-jar", "/app/demo-server-all.jar") |
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.
nit: remove
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.
Done.
} | ||
|
||
task dockerize { | ||
description = 'Builds the Client and API Server Docker images' | ||
task demoserver { |
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.
can demoserver and buildDemoImage be combined? if so I would keep the convention of naming the task dockerize, since we're in the demo distro, and the task we are doing is creating a docker image of the whole thing
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.
Ya good point, done.
group = 'docker' | ||
destFile project.file("${buildDir}/demoserver/Dockerfile") | ||
destFile project.file("${buildDir}/demo/Dockerfile") |
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.
looks like you started to rename demoserver -> demo in some places like above, which makes sense to me as we're now including the client in the image as well.
Can you do that everywhere else it's still called demo-server?
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.
done, I left the folder name, but everywhere else its just demo.
(Really demoserver is still a fine name, I just changed the docker image so there was no weirdness with old docker images.)
@@ -134,19 +134,37 @@ shadowJar { | |||
|
|||
shadowJar.dependsOn(createSecretsFile, createApiFile) | |||
|
|||
task createDemoServerDockerfile(type: Dockerfile) { | |||
description = 'Builds the Demo Server Dockerfile' | |||
task createDemoDockerfile(type: Dockerfile) { |
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.
nit: how about just createDockerfile?
before we were doing both client and server stuff, hence the different names
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.
Done.
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.
Nice, just some more documentation suggestions, otherwise looks good
Main suggestion is to use the term "demo-backend" (or something like that) to refer to the combined API + transfer worker jar we use for the demo.
Similarly, use consistent term to refer to the demo frontend which is nginx serving Angular.
Documentation/Developer.md
Outdated
@@ -63,39 +63,30 @@ limitations under the License. | |||
* The copyright should be added to all new files from now on (note: it might be collapsed so not immediately obvious) | |||
|
|||
## Creating the Docker Network |
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.
Should this header be renamed "Starting docker?"
The network stuff is all within the demo image now, right?
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.
did you see this one?
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.
Oh nope, sorry, fixed.
Documentation/Developer.md
Outdated
The following builds and optionally runs the demo server (containing the API and Transfer Worker) | ||
on `port:8080` | ||
## Building/Running locally | ||
The following builds and optionally runs the demo server locally |
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.
"Server" is still confusing to me because it makes me think backend.. maybe it's just me
I'm fine with keeping the name but can you add a comment here that the demo image contains both the frontend (served by nginx) and "demo backend" (API and worker combined in one process), which is (obviously) different than what you'd have in production? (there, API and transfer worker are separate images, and the frontend is Angular and deployed separately)
I just came up with the term "demo backend", we can call that something else, but I think we should have a name for it that we can use in documentation
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.
I called out it is all three parts.
@@ -118,9 +109,8 @@ The following runs the client-rest api | |||
* `ng serve --ssl --port 3000 --proxy-config proxy.conf.json` | |||
|
|||
The following builds and runs the demo-server (which contains the worker and the api) with the jettyrest transport to be |
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.
this documentation is out of date, right?
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.
It was mostly right, I added the extra port that was needed.
task createDemoServerDockerfile(type: Dockerfile) { | ||
description = 'Builds the Demo Server Dockerfile' | ||
task createDockerfile(type: Dockerfile) { | ||
description = 'Builds the Demo Dockerfile, which supports both the API and nginx' |
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.
how about:
...which includes both the frontend served by nginx, and a combined API + transfer worker backend
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.
Done
// Port to open up for the debugger | ||
exposePort 5005 | ||
|
||
// API server binary |
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.
It's not just API, it's the "demo backend" or whatever we decide to call it (API + transfer worker combined in one process)
can the jar be renamed to that too, i.e. demo-backend-all.jar?
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.
I think demo-server is better than demo-backend, as it includes the API and the worker, so it really the middle layer and the backend.
defaultCommand("java", "-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005", "-jar", "/app/demo-server-all.jar") | ||
// nginx configuration | ||
runCommand("apt-get update") | ||
runCommand("apt-get -y install nginx") |
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.
Ack
// create the user nginx runs as, matches user in nginx.config | ||
runCommand("adduser --disabled-password nginx") | ||
|
||
copyFile("src/config/client/nginx.conf", "/etc/nginx") |
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.
ah, misread this, copyFile is a Dockerfile directive right? forgot how that worked and read it as a scripted copy
maybe for clarity, document that these commands are all generating Dockerfile directives
copyFile("build/webapp/test-keys/server.key", "/etc/ssl") | ||
|
||
// Install supervisor to allow mutliple processes to run | ||
runCommand("apt-get install -y supervisor") |
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.
Ack
dependsOn shadowJar, createClientDockerfile, copyWebApp | ||
dockerFile = project.file("${buildDir}/client/Dockerfile") | ||
task dockerize(type: DockerBuildImage) { | ||
description = 'Builds the Demo Docker image including API server and nginx' |
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.
s/API/Demo backend
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.
Done
} | ||
|
||
task installToolsAndDockerize { | ||
description = 'Installs required build tools and builds the Client and API Server Docker images' | ||
description = 'Installs required build tools and builds the Client and API Server Docker image' |
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.
sometimes we say client, sometimes we say nginx, to refer to the same thing. I would use the same term consistently to be clear, or come up with a new one like "demo-frontend" - nginx serving Angular
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.
Done.
Documentation/Developer.md
Outdated
@@ -63,39 +63,30 @@ limitations under the License. | |||
* The copyright should be added to all new files from now on (note: it might be collapsed so not immediately obvious) | |||
|
|||
## Creating the Docker Network |
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.
did you see this one?
This should:
a) Make local development a little easier
b) Make it possible to publish a base docker image publicly that folks can easily try out. (We still need to solve #449 to make this possible).
This also makes a small change to use the datatransferproject repo name, which we own, so we can start publishing this image.