add configuration to use react-rust-postgres sample with Docker Dev Environments feature (#264)

Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
master
Guillaume Lours 2 years ago committed by GitHub
parent b53e4542c9
commit c781f1cbb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,51 @@
name: react-rust-postgres
services:
frontend:
build:
context: ../frontend
target: dev-envs
networks:
- client-side
ports:
- 3000:3000
volumes:
- /var/run/docker.sock:/var/run/docker.sock
backend:
build:
context: ../backend
target: dev-envs
environment:
- RUST_LOG=debug
- PG_DBNAME=postgres
- PG_HOST=db
- PG_USER=postgres
- PG_PASSWORD=mysecretpassword
- ADDRESS=0.0.0.0:8000
networks:
- client-side
- server-side
volumes:
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
- db
db:
image: postgres:12-alpine
restart: always
environment:
- POSTGRES_PASSWORD=mysecretpassword
networks:
- server-side
ports:
- 5432:5432
volumes:
- db-data:/var/lib/postgresql/data
networks:
client-side: {}
server-side: {}
volumes:
backend-cache: {}
db-data: {}

@ -1,3 +1,4 @@
# syntax=docker/dockerfile:1.4
FROM rust:buster AS base
ENV USER=root
@ -16,6 +17,23 @@ EXPOSE 8000
CMD [ "cargo", "run", "--offline" ]
FROM base AS dev-envs
EXPOSE 8000
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 [ "cargo", "run", "--offline" ]
FROM base AS builder
RUN cargo build --release --offline

@ -1,3 +1,4 @@
name: react-rust-postgres
services:
frontend:
build:

@ -1,3 +1,4 @@
# syntax=docker/dockerfile:1.4
FROM node:lts AS development
ENV CI=true
@ -11,6 +12,21 @@ COPY . /code
CMD [ "npm", "start" ]
FROM development 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 [ "npm", "start" ]
FROM development AS builder
RUN npm run build

@ -74,3 +74,11 @@ Removing react-rust-postgres_frontend_1 ... done
Removing react-rust-postgres_db_1 ... done
Removing network react-rust-postgres_default
```
## 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/react-rust-postgres`
![page](../dev-envs.png)

Loading…
Cancel
Save