add configuration to use nginx-golang-postgres sample with Docker Dev Environments feature
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
This commit is contained in:
parent
8784f95a69
commit
d189dc884d
35
nginx-golang-postgres/.docker/docker-compose.yaml
Normal file
35
nginx-golang-postgres/.docker/docker-compose.yaml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
services:
|
||||||
|
backend:
|
||||||
|
build:
|
||||||
|
context: backend
|
||||||
|
target: dev-envs
|
||||||
|
secrets:
|
||||||
|
- db-password
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
db:
|
||||||
|
image: postgres
|
||||||
|
restart: always
|
||||||
|
secrets:
|
||||||
|
- db-password
|
||||||
|
volumes:
|
||||||
|
- db-data:/var/lib/postgresql/data
|
||||||
|
environment:
|
||||||
|
- POSTGRES_DB=example
|
||||||
|
- POSTGRES_PASSWORD_FILE=/run/secrets/db-password
|
||||||
|
expose:
|
||||||
|
- 5432
|
||||||
|
|
||||||
|
proxy:
|
||||||
|
build: proxy
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
depends_on:
|
||||||
|
- backend
|
||||||
|
volumes:
|
||||||
|
db-data:
|
||||||
|
secrets:
|
||||||
|
db-password:
|
||||||
|
file: db/password.txt
|
@ -73,3 +73,11 @@ Stop and remove the containers
|
|||||||
```
|
```
|
||||||
$ docker compose down
|
$ docker compose down
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Use with Docker Development Environments
|
||||||
|
|
||||||
|
You can use this sample with the Dev Environments feature of Docker Desktop.
|
||||||
|
To develop directly frontend or the backend services inside containers, you just need to use the https git url of the sample:
|
||||||
|
`https://github.com/docker/awesome-compose/tree/master/nginx-golang-postgres`
|
||||||
|
|
||||||
|

|
@ -1,9 +1,29 @@
|
|||||||
FROM golang:1.13-alpine AS build
|
# syntax=docker/dockerfile:1.4
|
||||||
|
|
||||||
|
FROM --platform=$BUILDPLATFORM golang:1.18 AS build
|
||||||
WORKDIR /go/src/github.com/org/repo
|
WORKDIR /go/src/github.com/org/repo
|
||||||
|
COPY go.* .
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
ENV CGO_ENABLED=0
|
||||||
RUN go build -o server .
|
RUN go build -o server .
|
||||||
|
|
||||||
|
FROM build as dev-envs
|
||||||
|
|
||||||
|
RUN <<EOF
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y --no-install-recommends git
|
||||||
|
EOF
|
||||||
|
|
||||||
|
RUN <<EOF
|
||||||
|
useradd -s /bin/bash -m vscode
|
||||||
|
groupadd docker
|
||||||
|
usermod -aG docker vscode
|
||||||
|
EOF
|
||||||
|
# install Docker tools (cli, buildx, compose)
|
||||||
|
COPY --from=gloursdocker/docker / /
|
||||||
|
CMD ["go", "run", "main.go"]
|
||||||
|
|
||||||
FROM alpine:3.12
|
FROM alpine:3.12
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
COPY --from=build /go/src/github.com/org/repo/server /server
|
COPY --from=build /go/src/github.com/org/repo/server /server
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
module github.com/org/repo
|
module github.com/org/repo
|
||||||
|
|
||||||
go 1.13
|
go 1.18
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gorilla/context v1.1.1
|
github.com/gorilla/handlers v1.5.1
|
||||||
github.com/gorilla/handlers v1.3.0
|
github.com/gorilla/mux v1.8.0
|
||||||
github.com/gorilla/mux v1.6.2
|
github.com/lib/pq v1.10.6
|
||||||
github.com/lib/pq v1.10.3
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
require github.com/felixge/httpsnoop v1.0.1 // indirect
|
||||||
|
8
nginx-golang-postgres/backend/go.sum
Normal file
8
nginx-golang-postgres/backend/go.sum
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ=
|
||||||
|
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||||
|
github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4=
|
||||||
|
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
|
||||||
|
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
||||||
|
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
||||||
|
github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs=
|
||||||
|
github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
Loading…
Reference in New Issue
Block a user