Minimal Example
Setting up a new Angular 17 project (Node 18) as follows:
$ npm install -g @angular/cli@17
$ ng update @angular/core@17 @angular/cli@17
$ npm update
$ ng new example
stylesheets? $ SCSS
SSR? $ yes
$ cd example
$ ng serve
Connects just fine on localhost:4200
.
Deploying it with Docker does not work, because all the example Dockerfiles expect older Angular versions without SSR.
Seriously, guys. Before giving an answer try actually creating an Angular 17 SSR project and try if it works with your Dockerfile.
Docker Failures
I tried following these suggestions (remember to replace as necessary e.g.the node version node:12-slim
by node:18-slim
, the project name sample-angular-app
by the project name example
, doing the ports correctly etc.):
- https://dev.to/marwan01/deploy-an-angular-app-using-google-cloud-run-3p4a (there is no
server.js
) - https://dev.to/rodrigokamada/creating-and-running-an-angular-application-in-a-docker-container-40mk (builds but no connection possible - just gives the NGIX default page).
- https://levioconsulting.com/insights/how-to-dockerize-an-angular-application-with-nginx/ (builds but no connection possible {connection reset} - and completely rebuilds the application on each docker run instead of only once).
- https://blog.stackademic.com/deploy-your-angular-app-with-docker-and-nginx-a5b0a3c1d06b (the Dockerfile has a syntax error, and when built cannot connect {connection reset})
- https://plainenglish.io/blog/how-to-dockerize-angular-application-3cd67e963832 (cannot connect {just gives the NGIX default page}, but at least it only builds once)
- https://github.com/coltenkrauter/angular-ssr-example/blob/stable/Dockerfile.ssr (expects pre-Angular 17 SSR, needs to be rewritten, then no connection {refused to connect})
browser
folder too. – Neoprene