diff --git a/samples/angular/README.md b/samples/angular/README.md new file mode 100644 index 0000000..f1710e3 --- /dev/null +++ b/samples/angular/README.md @@ -0,0 +1,70 @@ +## Compose sample - Angular service + +Project structure: +``` +. +├── angular +│   ├── Dockerfile +│   ├── ... +│   ├── ... +│   .... +│   +├── docker-compose.yaml +└── README.md + +``` + +_docker-compose.yaml_ +``` +version: "3.7" +services: + angular: + build: angular + ports: + - 80:4200 + ... + +``` +The compose file defines an application with one service `angular`. The image for the service is built with the Dockerfile inside the `angular` directory (build parameter). + +When deploying the application, docker-compose maps the container port 4200 to port 80 of the host as specified in the file. +Make sure port 80 is not being used by another container, otherwise the port should be changed. + + +## Deploy with docker-compose + +``` +$ docker-compose up -d +Creating network "angular_default" with the default driver +Building angular +Step 1/7 : FROM node:10 +10: Pulling from library/node +c0c53f743a40: Pull complete +... +... +Successfully built efea5cef6851 +Successfully tagged angular_web:latest +WARNING: Image for service web was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`. +Creating angular_web_1 ... done +``` + + +## Expected result + +Listing containers must show a container running and the port mapping as below: +``` +$ docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +6884c228388e angular_web "docker-entrypoint.s…" 42 seconds ago Up 36 seconds 0.0.0.0:80->4200/tcp angular_web_1 + +``` + +Open a browser and go to localhost. + +![page](http://output.jpg) + +Stop and remove the container + +``` +$ docker-compose down +``` \ No newline at end of file diff --git a/samples/angular/angular/src/favicon.ico b/samples/angular/angular/src/favicon.ico index 997406a..523925f 100644 Binary files a/samples/angular/angular/src/favicon.ico and b/samples/angular/angular/src/favicon.ico differ diff --git a/samples/angular/docker-compose.yaml b/samples/angular/docker-compose.yaml index 549db46..fb02ab4 100644 --- a/samples/angular/docker-compose.yaml +++ b/samples/angular/docker-compose.yaml @@ -1,6 +1,6 @@ version: "3.7" services: - angular: + web: build: angular ports: - 80:4200 diff --git a/samples/angular/output.jpg b/samples/angular/output.jpg new file mode 100644 index 0000000..e96e73f Binary files /dev/null and b/samples/angular/output.jpg differ