Signed-off-by: Anca Iordache <anca.iordache@docker.com>pull/3/head
parent
9c829ac4ba
commit
48341239de
@ -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"] |
||||
|
||||
|
@ -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: . |
||||
|
@ -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)) |
||||
} |
@ -1,6 +0,0 @@ |
||||
server { |
||||
listen 80; |
||||
location / { |
||||
proxy_pass http://backend:80; |
||||
} |
||||
} |
@ -1,5 +1,5 @@ |
||||
|
||||
version: "3.6" |
||||
version: "3.7" |
||||
services: |
||||
frontend: |
||||
build: frontend |
@ -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 |
@ -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 |
||||
``` |
@ -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 |
||||
``` |
After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 38 KiB |
Loading…
Reference in new issue