update readme.md for all samples

Signed-off-by: Anca Iordache <anca.iordache@docker.com>
This commit is contained in:
Anca Iordache 2020-03-06 19:25:16 +01:00
parent 9c829ac4ba
commit 48341239de
30 changed files with 841 additions and 102 deletions

View File

@ -22,31 +22,30 @@ The root directory of each sample contains the docker-compose.yaml describing th
docker-compose up -d
```
Check the `README.md` of each sample to get more details on the structure and what is the expected output.
To stop and remove the running containers of the sample application do:
To stop and remove the all containers of the sample application run:
```
docker-compose down
```
## Contents
*Samples of docker-compose applications with multiple integrated services:*
- [`Asp.NET/MS-SQL`](samples/aspnet-mssql/README.md) -- sample asp\\.net core application with MS SQL server database
- [`Flask / NGINX / MySQL`](samples/nginx-flask-mysql/README.md) -- sample Python/Flask application with an Nginx proxy and a MySQL database
- [`Go / NGINX / MySQL`](samples/nginx-golang-mysql/README.md) -- sample Go application with an Nginx proxy and a MySQL database
- [`Go / NGINX / PostgreSQL`](samples/nginx-golang-postgres/README.md) -- sample Go application with an Nginx proxy and a PostgreSQL database
- [`Java / MySQL`](samples/sparkjava-mysql/README.md) -- sample Java application and a MySQL database
- [`NGINX / Go`](samples/nginx-gohttp_1/README.md) -- sample Nginx application with a Go backend
- [`NGINX / Go`](samples/nginx-gohttp_2/README.md) -- another Nginx sample application with a Go backend
- [`React / Spring / MySQL`](samples/react-java-mysql/README.md) -- sample React application with a Spring backend and a MySQL database
- [`React / Express / MySQL`](samples/react-express-mysql/README.md) -- sample React application with a NodeJS backend and a MySQL database
- [`Spring / PostgreSQL`](samples/spring-postgres/README.md) -- sample Java application with Spring framework and a Postgres database
- [`ASP.NET / MS-SQL`](samples/aspnet-mssql) -- sample ASP.NET core application with MS SQL server database
- [`Go / NGINX / MySQL`](samples/nginx-golang-mysql) -- sample Go application with an Nginx proxy and a MySQL database
- [`Go / NGINX / PostgreSQL`](samples/nginx-golang-postgres) -- sample Go application with an Nginx proxy and a PostgreSQL database
- [`Java Spark / MySQL`](samples/sparkjava-mysql) -- sample Java application and a MySQL database
- [`NGINX / Flask / MongoDB`](samples/nginx-flask-mongo) -- sample Python/Flask application with Nginx proxy and a Mongo database
- [`NGINX / Flask / MySQL`](samples/nginx-flask-mysql) -- sample Python/Flask application with an Nginx proxy and a MySQL database
- [`NGINX / Go`](samples/nginx-golang) -- sample Nginx proxy with a Go backend
- [`React / Spring / MySQL`](samples/react-java-mysql) -- sample React application with a Spring backend and a MySQL database
- [`React / Express / MySQL`](samples/react-express-mysql) -- sample React application with a NodeJS backend and a MySQL database
- [`Spring / PostgreSQL`](samples/spring-postgres) -- sample Java application with Spring framework and a Postgres database
*Single service samples:*
- [`Angular`](samples/angular/README.md)
- [`VueJS`](samples/vuejs/README.md)
- [`Angular`](samples/angular)
- [`Spark`](samples/sparkjava)
- [`VueJS`](samples/vuejs)
## Contribute

View File

@ -1,4 +1,5 @@
## Compose sample - Angular service
## Compose sample
### Angular service
Project structure:
```
@ -11,7 +12,7 @@ Project structure:
└── docker-compose.yaml
```
_docker-compose.yaml_
[_docker-compose.yaml_](docker-compose.yaml)
```
version: "3.7"
services:
@ -58,7 +59,7 @@ CONTAINER ID IMAGE COMMAND CREATED
After the application starts, navigate to `http://localhost:80` in your web browser.
![page](https://github.com/aiordache/awesome-compose/blob/master/samples/angular/output.jpg)
![page](output.jpg)
Stop and remove the container

View File

@ -1,4 +1,4 @@
## Compose sample - ASP.Net
## Compose sample application: ASP.NET with MS SQL server database
Project structure:
```
@ -12,17 +12,18 @@ Project structure:
└── docker-compose.yaml
```
_docker-compose.yaml_
[_docker-compose.yaml_](docker-compose.yaml)
```
version: "3.7"
services:
web:
build: app
ports:
- 80:80
db:
image: microsoft/mssql-server-linux
...
```
The compose file defines an application with one service `web`. The image for the service is built with the Dockerfile inside the `app` directory (build parameter).
The compose file defines an application with two services `web` and `db`. The image for the web service is built with the Dockerfile inside the `app` directory (build parameter).
When deploying the application, docker-compose maps the container port 80 to port 80 of the host as specified in the file.
Make sure port 80 on the host is not being used by another container, otherwise the port should be changed.
@ -32,7 +33,6 @@ Make sure port 80 on the host is not being used by another container, otherwise
```
$ docker-compose up -d
$ compose up -d
Creating network "aspnet-mssql_default" with the default driver
Building web
Step 1/13 : FROM mcr.microsoft.com/dotnet/core/sdk:2.1 AS build
@ -59,9 +59,9 @@ CONTAINER ID IMAGE COMMAND CREATED
After the application starts, navigate to `http://localhost:80` in your web browser.
![page](https://github.com/aiordache/awesome-compose/blob/master/samples/aspnet-mssql/output.jpg)
![page](output.jpg)
Stop and remove the container
Stop and remove the containers
```
$ docker-compose down

View File

@ -0,0 +1,71 @@
## Compose sample application
### Python/Flask application with Nginx proxy and a Mongo database
Project structure:
```
.
├── docker-compose.yaml
├── flask
│   ├── Dockerfile
│   ├── requirements.txt
│   └── server.py
└── nginx
   └── nginx.conf
```
[_docker-compose.yaml_](docker-compose.yaml)
```
services:
web:
build: app
ports:
- 80:80
backend:
build: flask
...
mongo:
image: mongo
```
The compose file defines an application with three services `web`, `backend` and `db`.
When deploying the application, docker-compose maps port 80 of the web service container to port 80 of the host as specified in the file.
Make sure port 80 on the host is not being used by another container, otherwise the port should be changed.
## Deploy with docker-compose
```
$ docker-compose up -d
Creating network "nginx-flask-mongo_default" with the default driver
Pulling mongo (mongo:)...
latest: Pulling from library/mongo
423ae2b273f4: Pull complete
...
...
Status: Downloaded newer image for nginx:latest
Creating nginx-flask-mongo_mongo_1 ... done
Creating nginx-flask-mongo_backend_1 ... done
Creating nginx-flask-mongo_web_1 ... done
```
## Expected result
Listing containers must show two containers running and the port mapping as below:
```
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a0f4ebe686ff nginx "/bin/bash -c 'envsu…" About a minute ago Up About a minute 0.0.0.0:8080->80/tcp nginx-flask-mongo_web_1
dba87a080821 nginx-flask-mongo_backend "./server.py" About a minute ago Up About a minute nginx-flask-mongo_backend_1
d7eea5481c77 mongo "docker-entrypoint.s…" About a minute ago Up About a minute 27017/tcp nginx-flask-mongo_mongo_1
```
After the application starts, navigate to `http://localhost:80` in your web browser or run:
```
$ curl localhost:80
Hello fom the MongoDB client!
```
Stop and remove the containers
```
$ docker-compose down
```

View File

@ -1,4 +1,4 @@
version: "3"
version: "3.7"
services:
web:
image: nginx

View File

@ -0,0 +1,69 @@
## Compose sample application
### Python/Flask with Nginx proxy and MySQL database
Project structure:
```
.
├── docker-compose.yaml
├── flask
│   ├── Dockerfile
│   ├── requirements.txt
│   └── server.py
└── nginx
   └── nginx.conf
```
[_docker-compose.yaml_](docker-compose.yaml)
```
services:
backend:
build: backend
...
db:
image: mysql:5.7
...
proxy:
build: proxy
...
```
The compose file defines an application with three services `proxy`, `backend` and `db`.
When deploying the application, docker-compose maps port 80 of the proxy service container to port 80 of the host as specified in the file.
Make sure port 80 on the host is not already being in use.
## Deploy with docker-compose
```
$ docker-compose up -d
Creating network "nginx-flask-mysql_default" with the default driver
Pulling db (mysql:5.7)...
5.7: Pulling from library/mysql
...
...
WARNING: Image for service proxy was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating nginx-flask-mysql_db_1 ... done
Creating nginx-flask-mysql_backend_1 ... done
Creating nginx-flask-mysql_proxy_1 ... done
```
## Expected result
Listing containers must show two containers running and the port mapping as below:
```
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c65ecef87e85 nginx-flask-mysql_proxy "nginx -g 'daemon of…" About a minute ago Up About a minute 0.0.0.0:80->80/tcp nginx-flask-mysql_proxy_1
96ccc0a5342f nginx-flask-mysql_backend "/bin/sh -c 'flask r…" About a minute ago Up About a minute 5000/tcp nginx-flask-mysql_backend_1
39327313a142 mysql:5.7 "docker-entrypoint.s…" About a minute ago Up About a minute 3306/tcp, 33060/tcp nginx-flask-mysql_db_1
```
After the application starts, navigate to `http://localhost:80` in your web browser or run:
```
$ curl localhost:80
Hello world
```
Stop and remove the containers
```
$ docker-compose down
```

View File

@ -1,11 +0,0 @@
FROM golang:1.13 AS builder
WORKDIR /compose/hello-docker
COPY main.go main.go
RUN CGO_ENABLED=0 go build -o backend main.go
FROM scratch
COPY --from=builder /compose/hello-docker/backend /usr/local/bin/backend
CMD ["/usr/local/bin/backend"]

View File

@ -1,14 +0,0 @@
version: "3.6"
services:
frontend:
image: nginx
ports:
- 8080:80
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
depends_on:
- backend
backend:
build: .

View File

@ -1,30 +0,0 @@
package main
import (
"fmt"
"log"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Println(r.URL.RawQuery)
fmt.Fprintf(w, `
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
{ / ===-
\______ O __/
\ \ __/
\____\_______/
Hello from Docker!
`)
}
func main() {
http.HandleFunc("/", handler)
log.Fatal(http.ListenAndServe(":80", nil))
}

View File

@ -1,6 +0,0 @@
server {
listen 80;
location / {
proxy_pass http://backend:80;
}
}

View File

@ -0,0 +1,79 @@
## Compose sample application
### Go server with an Nginx proxy and a MySQL database
Project structure:
```
.
├── backend
│   ├── Dockerfile
│   ├── go.mod
│   └── main.go
├── db
│   └── password.txt
├── docker-compose.yaml
├── proxy
│   ├── conf
│   └── Dockerfile
└── README.md
```
[_docker-compose.yaml_](docker-compose.yaml)
```
services:
backend:
build: backend
...
db:
image: mysql:5.7
...
proxy:
build: proxy
ports:
- 80:80
...
```
The compose file defines an application with three services `proxy`, `backend` and `db`.
When deploying the application, docker-compose maps port 80 of the proxy service container to port 80 of the host as specified in the file.
Make sure port 80 on the host is not already being in use.
## Deploy with docker-compose
```
$ docker-compose up -d
Creating network "nginx-golang-mysql_default" with the default driver
Building backend
Step 1/8 : FROM golang:1.13-alpine AS build
1.13-alpine: Pulling from library/golang
...
Successfully built 5f7c899f9b49
Successfully tagged nginx-golang-mysql_proxy:latest
WARNING: Image for service proxy was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating nginx-golang-mysql_db_1 ... done
Creating nginx-golang-mysql_backend_1 ... done
Creating nginx-golang-mysql_proxy_1 ... done
```
## Expected result
Listing containers must show two containers running and the port mapping as below:
```
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8906b14c5ad1 nginx-golang-mysql_proxy "nginx -g 'daemon of…" 2 minutes ago Up 2 minutes 0.0.0.0:80->80/tcp nginx-golang-mysq
l_proxy_1
13e0e0a7715a nginx-golang-mysql_backend "/server" 2 minutes ago Up 2 minutes 8000/tcp nginx-golang-mysq
l_backend_1
ca8c5975d205 mysql:5.7 "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 3306/tcp, 33060/tcp nginx-golang-mysq
l_db_1
```
After the application starts, navigate to `http://localhost:80` in your web browser or run:
```
$ curl localhost:80
["Blog post #0","Blog post #1","Blog post #2","Blog post #3","Blog post #4"]
```
Stop and remove the containers
```
$ docker-compose down
```

View File

@ -0,0 +1,75 @@
## Compose sample application
### Go server with an Nginx proxy and a Postgres database
Project structure:
```
.
├── backend
│   ├── Dockerfile
│   ├── go.mod
│   └── main.go
├── db
│   └── password.txt
├── docker-compose.yaml
├── proxy
│   ├── conf
│   └── Dockerfile
└── README.md
```
[_docker-compose.yaml_](docker-compose.yaml)
```
services:
backend:
build: backend
...
db:
image: postgres
...
proxy:
build: proxy
ports:
- 80:80
...
```
The compose file defines an application with three services `proxy`, `backend` and `db`.
When deploying the application, docker-compose maps port 80 of the proxy service container to port 80 of the host as specified in the file.
Make sure port 80 on the host is not already being in use.
## Deploy with docker-compose
```
$ docker-compose up -d
Creating network "nginx-golang-postgres_default" with the default driver
Pulling db (postgres:)...
latest: Pulling from library/postgres
...
Successfully built 5f7c899f9b49
Successfully tagged nginx-golang-postgres_proxy:latest
WARNING: Image for service proxy was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating nginx-golang-postgres_db_1 ... done
Creating nginx-golang-postgres_backend_1 ... done
Creating nginx-golang-postgres_proxy_1 ... done
```
## Expected result
Listing containers must show two containers running and the port mapping as below:
```
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5e3ecd0289c0 nginx-golang-postgres_proxy "nginx -g 'daemon of…" 48 seconds ago Up 48 seconds 0.0.0.0:80->80/tcp nginx-golang-postgres_proxy_1
ffa1410b1c8a nginx-golang-postgres_backend "/server" 49 seconds ago Up 48 seconds 8000/tcp nginx-golang-postgres_backend_1
e63be7db7cbc postgres "docker-entrypoint.s…" 49 seconds ago Up 49 seconds 5432/tcp nginx-golang-postgres_db_1
```
After the application starts, navigate to `http://localhost:80` in your web browser or run:
```
$ curl localhost:80
["Blog post #0","Blog post #1","Blog post #2","Blog post #3","Blog post #4"]
```
Stop and remove the containers
```
$ docker-compose down
```

View File

@ -0,0 +1,78 @@
## Compose sample application
### NGINX proxy with GO backend
Project structure:
```
.
├── backend
│   ├── Dockerfile
│   └── main.go
├── docker-compose.yml
├── frontend
│   ├── Dockerfile
│   └── nginx.conf
└── README.md
```
[_docker-compose.yaml_](docker-compose.yaml)
```
version: "3.7"
services:
frontend:
build: frontend
ports:
- 8080:80
backend:
build: backend
```
The compose file defines an application with two services `frontend` and `backend`.
When deploying the application, docker-compose maps port 80 of the frontend service container to port 8080 of the host as specified in the file.
Make sure port 8080 on the host is not already being in use.
## Deploy with docker-compose
```
$ docker-compose up -d
Creating network "nginx-golang_default" with the default driver
Building backend
Step 1/7 : FROM golang:1.13 AS build
1.13: Pulling from library/golang
...
Successfully built 4b24f27138cc
Successfully tagged nginx-golang_frontend:latest
WARNING: Image for service frontend was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating nginx-golang_backend_1 ... done
Creating nginx-golang_frontend_1 ... done
```
## Expected result
Listing containers must show two containers running and the port mapping as below:
```
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8bd5b0d78e73 nginx-golang_frontend "nginx -g 'daemon of…" 53 seconds ago Up 52 seconds 0.0.0.0:8080->80/tcp nginx-golang_frontend_1
56f929c240a0 nginx-golang_backend "/usr/local/bin/back…" 53 seconds ago Up 53 seconds nginx-golang_backend_1
```
After the application starts, navigate to `http://localhost:8080` in your web browser or run:
```
$ curl localhost:8080
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
{ / ===-
\______ O __/
\ \ __/
\____\_______/
Hello from Docker!
```
Stop and remove the containers
```
$ docker-compose down
```

View File

@ -1,5 +1,5 @@
version: "3.6"
version: "3.7"
services:
frontend:
build: frontend

View File

@ -0,0 +1,87 @@
## Compose sample application
### React application with a NodeJS backend and a MySQL database
Project structure:
```
.
├── backend
│   ├── Dockerfile
│   ...
├── db
│   └── password.txt
├── docker-compose.yaml
├── frontend
│   ├── ...
│   └── Dockerfile
└── README.md
```
[_docker-compose.yaml_](docker-compose.yaml)
```
services:
backend:
build: backend
...
db:
image: postgres
...
frontend:
build: frontend
ports:
- 80:9000
...
```
The compose file defines an application with three services `frontend`, `backend` and `db`.
When deploying the application, docker-compose maps port 80 of the frontend service container to port 9000 of the host as specified in the file.
Make sure port 80 on the host is not already being in use.
## Deploy with docker-compose
```
$ docker-compose up -d
Creating network "react-express-mysql_default" with the default driver
Building backend
Step 1/16 : FROM node:10
---> aa6432763c11
...
Successfully tagged react-express-mysql_frontend:latest
WARNING: Image for service frontend was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating react-express-mysql_db_1 ... done
Creating react-express-mysql_backend_1 ... done
Creating react-express-mysql_frontend_1 ... done
```
## Expected result
Listing containers must show two containers running and the port mapping as below:
```
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5e3ecd0289c0 nginx-golang-postgres_proxy "nginx -g 'daemon of…" 48 seconds ago Up 48 seconds 0.0.0.0:80->80/tcp nginx-golang-postgres_proxy_1
ffa1410b1c8a nginx-golang-postgres_backend "/server" 49 seconds ago Up 48 seconds 8000/tcp nginx-golang-postgres_backend_1
e63be7db7cbc postgres "docker-entrypoint.s…" 49 seconds ago Up 49 seconds 5432/tcp nginx-golang-postgres_db_1
```
After the application starts, navigate to `http://localhost:80` in your web browser to get a colorful message.
```
My New React App
```
The backend service container has the port 80 mapped to 8080 on the host.
```
$ curl localhost:8080
Hello Docker World
```
Stop and remove the containers
```
$ docker-compose down
Stopping react-express-mysql_frontend_1 ... done
Stopping react-express-mysql_backend_1 ... done
Stopping react-express-mysql_db_1 ... done
Removing react-express-mysql_frontend_1 ... done
Removing react-express-mysql_backend_1 ... done
Removing react-express-mysql_db_1 ... done
Removing network react-express-mysql_default
```

View File

@ -1,12 +0,0 @@
FROM node:10 as build
RUN mkdir /project
WORKDIR /project
COPY . .
RUN yarn install
RUN yarn run package
FROM nginx:1.13-alpine
COPY config/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /project/dist /usr/share/nginx/html

View File

@ -0,0 +1,80 @@
## Compose sample application
### React application with a NodeJS backend and a MySQL database
Project structure:
```
.
├── backend
│   ├── Dockerfile
│   ...
├── db
│   └── password.txt
├── docker-compose.yaml
├── frontend
│   ├── ...
│   └── Dockerfile
└── README.md
```
[_docker-compose.yaml_](docker-compose.yaml)
```
services:
backend:
build: backend
...
db:
image: mysql:5.7
...
frontend:
build: frontend
ports:
- 80:9000
...
```
The compose file defines an application with three services `frontend`, `backend` and `db`.
When deploying the application, docker-compose maps port 80 of the frontend service container to port 9000 of the host as specified in the file.
Make sure port 80 on the host is not already being in use.
## Deploy with docker-compose
```
$ docker-compose up -d
Creating network "react-java-mysql_default" with the default driver
Building backend
Step 1/10 : FROM maven:3.5-jdk-9 AS build
...
Successfully tagged react-java-mysql_frontend:latest
WARNING: Image for service frontend was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating react-java-mysql_frontend_1 ... done
Creating react-java-mysql_db_1 ... done
Creating react-java-mysql_backend_1 ... done
```
## Expected result
Listing containers must show two containers running and the port mapping as below:
```
$ docker ps
ONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a63dee74d79e react-java-mysql_backend "java -Djava.securit…" 39 seconds ago Up 37 seconds react-java-mysql_backend_1
6a7364c0812e react-java-mysql_frontend "docker-entrypoint.s…" 39 seconds ago Up 33 seconds 0.0.0.0:80->9000/tcp react-java-mysql_frontend_1
b176b18fbec4 mysql:5.7 "docker-entrypoint.s…" 39 seconds ago Up 37 seconds 3306/tcp, 33060/tcp react-java-mysql_db_1
e63be7db7cbc postgres "docker-entrypoint.s…" 2 hours ago Up 16 minutes 5432/tcp nginx-golang-postgres_db_1
```
After the application starts, navigate to `http://localhost:80` in your web browser to get a colorful message.
```
My New React App
```
Stop and remove the containers
```
$ docker-compose down
Stopping react-java-mysql_backend_1 ... done
Stopping react-java-mysql_frontend_1 ... done
Stopping react-java-mysql_db_1 ... done
Removing react-java-mysql_backend_1 ... done
Removing react-java-mysql_frontend_1 ... done
Removing react-java-mysql_db_1 ... done
Removing network react-java-mysql_default
```

View File

@ -0,0 +1,70 @@
## Compose sample application
### Java Spark application with MySQL database
Project structure:
```
.
├── backend
│   ├── Dockerfile
│   └── ...
├── db
│   └── password.txt
├── docker-compose.yaml
└── README.md
```
[_docker-compose.yaml_](docker-compose.yaml)
```
version: "3.7"
services:
backend:
build: backend
ports:
- 80:8080
db:
image: mysql:5.7
...
```
The compose file defines an application with two services `backend` and `db`.
When deploying the application, docker-compose maps port 8080 of the backend service container to port 80 of the host as specified in the file.
Make sure port 80 on the host is not already being in use.
## Deploy with docker-compose
```
$ docker-compose up -d
Creating network "sparkjava-mysql_default" with the default driver
Building backend
...
Successfully tagged sparkjava-mysql_backend:latest
WARNING: Image for service backend was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating sparkjava-mysql_db_1 ... done
Creating sparkjava-mysql_backend_1 ... done
```
## Expected result
Listing containers must show two containers running and the port mapping as below:
```
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ee1e4f05d9f6 sparkjava-mysql_backend "/bin/sh -c 'java -j…" 44 seconds ago Up 43 seconds 0.0.0.0:80->8080/tcp sparkjava-mysql_backend_1
716025ddf65b mysql:5.7 "docker-entrypoint.s…" 44 seconds ago Up 43 seconds 3306/tcp, 33060/tcp sparkjava-mysql_db_1
```
After the application starts, run:
```
$ curl localhost:80
["Blog post #0","Blog post #1","Blog post #2","Blog post #3","Blog post #4"]
```
Stop and remove the containers
```
$ docker-compose down
Stopping sparkjava-mysql_backend_1 ... done
Stopping sparkjava-mysql_db_1 ... done
Removing sparkjava-mysql_backend_1 ... done
Removing sparkjava-mysql_db_1 ... done
Removing network sparkjava-mysql_default
```

View File

@ -2,7 +2,6 @@ version: "3.7"
services:
backend:
build: backend
image: docker.io/docker/back
ports:
- 80:8080
secrets:

View File

@ -0,0 +1,62 @@
## Compose sample application
### Spark Java
Project structure:
```
.
├── docker-compose.yaml
├── README.md
└── sparkjava
├── Dockerfile
└── ...
```
[_docker-compose.yaml_](docker-compose.yaml)
```
version: "3.7"
services:
sparkjava:
build: sparkjava
ports:
- 80:8080
```
The compose file defines an application with one service `sparkjava`.
When deploying the application, docker-compose maps port 8080 of the sparkjava service container to port 80 of the host as specified in the file.
Make sure port 80 on the host is not already being in use.
## Deploy with docker-compose
```
$ docker-compose up -d
Creating network "sparkjava_default" with the default driver
Building sparkjava
Step 1/9 : FROM maven:3.5-jdk-8-alpine AS build
3.5-jdk-8-alpine: Pulling from library/maven
...
Successfully tagged sparkjava_sparkjava:latest
WARNING: Image for service sparkjava was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating sparkjava_sparkjava_1 ... done
```
## Expected result
Listing containers must show two containers running and the port mapping as below:
```
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5af94cb25394 sparkjava_sparkjava "/bin/sh -c 'java -j…" 20 seconds ago Up 19 seconds 0.0.0.0:80->8080/tcp sparkjava_sparkjava_1
```
After the application starts, navigate to `http://localhost:80` in your web browser or run:
```
$ curl localhost:80
Hello world
```
Stop and remove the containers
```
$ docker-compose down
Stopping sparkjava_sparkjava_1 ... done
Removing sparkjava_sparkjava_1 ... done
Removing network sparkjava_default
```

View File

@ -0,0 +1,80 @@
## Compose sample application
### Java application with Spring framework and a Postgres database
Project structure:
```
.
├── backend
│   ├── Dockerfile
│   └── ...
├── db
│   └── password.txt
├── docker-compose.yaml
└── README.md
```
[_docker-compose.yaml_](docker-compose.yaml)
```
version: "3.7"
services:
backend:
build: backend
ports:
- 80:8080
db:
image: postgres
...
```
The compose file defines an application with two services `backend` and `db`.
When deploying the application, docker-compose maps port 8080 of the backend service container to port 80 of the host as specified in the file.
Make sure port 80 on the host is not already being in use.
## Deploy with docker-compose
```
$ docker-compose up -d
Creating network "spring-postgres_default" with the default driver
Building backend
Step 1/11 : FROM maven:3.5-jdk-9 AS build
3.5-jdk-9: Pulling from library/maven
...
Successfully tagged spring-postgres_backend:latest
WARNING: Image for service backend was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating spring-postgres_backend_1 ... done
Creating spring-postgres_db_1 ... done
```
## Expected result
Listing containers must show two containers running and the port mapping as below:
```
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
56236f640eaa postgres "docker-entrypoint.s…" 29 seconds ago Up 28 seconds 5432/tcp spring-postgres_db_1
6e69472dc2c0 spring-postgres_backend "java -Djava.securit…" 29 seconds ago Up 28 seconds 0.0.0.0:80->8080/tcp spring-postgres_backend_1
```
After the application starts, navigate to `http://localhost:80` in your web browse or run:
```
$ curl localhost:80
<!DOCTYPE HTML>
<html>
<head>
<title>Getting Started: Serving Web Content</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<p>Hello from Docker!</p>
</body>
```
Stop and remove the containers
```
$ docker-compose down
Stopping spring-postgres_db_1 ... done
Stopping spring-postgres_backend_1 ... done
Removing spring-postgres_db_1 ... done
Removing spring-postgres_backend_1 ... done
Removing network spring-postgres_default
```

62
samples/vuejs/README.md Normal file
View File

@ -0,0 +1,62 @@
## Compose sample application
### VueJS
Project structure:
```
.
├── docker-compose.yaml
├── README.md
└── vuejs
├── Dockerfile
└── ...
```
[_docker-compose.yaml_](docker-compose.yaml)
```
version: "3.7"
services:
web:
build: vuejs
ports:
- 80:8080
volumes:
- ./vuejs:/project
- /project/node_modules
```
The compose file defines an application with one service `sparkjava`.
When deploying the application, docker-compose maps port 8080 of the web service container to port 80 of the host as specified in the file.
Make sure port 80 on the host is not already being in use.
## Deploy with docker-compose
```
$ docker-compose up -d
Creating network "vuejs_default" with the default driver
Building web
Step 1/8 : FROM node:10
...
Successfully tagged vuejs_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 vuejs_web_1 ... done
```
## Expected result
Listing containers must show two containers running and the port mapping as below:
```
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
701c02bb97b1 vuejs_web "docker-entrypoint.s…" 49 seconds ago Up 46 seconds 0.0.0.0:80->8080/tcp vuejs_web_1
```
After the application starts, navigate to `http://localhost:80` in your web browser.
![page](output.jpg)
Stop and remove the containers
```
$ docker-compose down
Stopping vuejs_web_1 ... done
Removing vuejs_web_1 ... done
Removing network vuejs_default
```

View File

@ -1,6 +1,6 @@
version: "3.7"
services:
vuejs:
web:
build: vuejs
ports:
- 80:8080

BIN
samples/vuejs/output.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 38 KiB