File tree 5 files changed +94
-0
lines changed
5 files changed +94
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : react-rust-postgres
2
+ services :
3
+ frontend :
4
+ build :
5
+ context : ../frontend
6
+ target : dev-envs
7
+ networks :
8
+ - client-side
9
+ ports :
10
+ - 3000:3000
11
+ volumes :
12
+ - /var/run/docker.sock:/var/run/docker.sock
13
+
14
+ backend :
15
+ build :
16
+ context : ../backend
17
+ target : dev-envs
18
+ environment :
19
+ - RUST_LOG=debug
20
+ - PG_DBNAME=postgres
21
+ - PG_HOST=db
22
+ - PG_USER=postgres
23
+ - PG_PASSWORD=mysecretpassword
24
+ - ADDRESS=0.0.0.0:8000
25
+ networks :
26
+ - client-side
27
+ - server-side
28
+ volumes :
29
+ - /var/run/docker.sock:/var/run/docker.sock
30
+ depends_on :
31
+ - db
32
+
33
+ db :
34
+ image : postgres:12-alpine
35
+ restart : always
36
+ environment :
37
+ - POSTGRES_PASSWORD=mysecretpassword
38
+ networks :
39
+ - server-side
40
+ ports :
41
+ - 5432:5432
42
+ volumes :
43
+ - db-data:/var/lib/postgresql/data
44
+
45
+ networks :
46
+ client-side : {}
47
+ server-side : {}
48
+
49
+ volumes :
50
+ backend-cache : {}
51
+ db-data : {}
Original file line number Diff line number Diff line change
1
+ # syntax=docker/dockerfile:1.4
1
2
FROM rust:buster AS base
2
3
3
4
ENV USER=root
@@ -16,6 +17,23 @@ EXPOSE 8000
16
17
17
18
CMD [ "cargo" , "run" , "--offline" ]
18
19
20
+ FROM base AS dev-envs
21
+
22
+ EXPOSE 8000
23
+ RUN <<EOF
24
+ apt-get update
25
+ apt-get install -y --no-install-recommends git
26
+ EOF
27
+
28
+ RUN <<EOF
29
+ useradd -s /bin/bash -m vscode
30
+ groupadd docker
31
+ usermod -aG docker vscode
32
+ EOF
33
+ # install Docker tools (cli, buildx, compose)
34
+ COPY --from=gloursdocker/docker / /
35
+ CMD [ "cargo" , "run" , "--offline" ]
36
+
19
37
FROM base AS builder
20
38
21
39
RUN cargo build --release --offline
Original file line number Diff line number Diff line change
1
+ name : react-rust-postgres
1
2
services :
2
3
frontend :
3
4
build :
Original file line number Diff line number Diff line change
1
+ # syntax=docker/dockerfile:1.4
1
2
FROM node:lts AS development
2
3
3
4
ENV CI=true
@@ -11,6 +12,21 @@ COPY . /code
11
12
12
13
CMD [ "npm" , "start" ]
13
14
15
+ FROM development as dev-envs
16
+ RUN <<EOF
17
+ apt-get update
18
+ apt-get install -y --no-install-recommends git
19
+ EOF
20
+
21
+ RUN <<EOF
22
+ useradd -s /bin/bash -m vscode
23
+ groupadd docker
24
+ usermod -aG docker vscode
25
+ EOF
26
+ # install Docker tools (cli, buildx, compose)
27
+ COPY --from=gloursdocker/docker / /
28
+ CMD [ "npm" , "start" ]
29
+
14
30
FROM development AS builder
15
31
16
32
RUN npm run build
Original file line number Diff line number Diff line change @@ -74,3 +74,11 @@ Removing react-rust-postgres_frontend_1 ... done
74
74
Removing react-rust-postgres_db_1 ... done
75
75
Removing network react-rust-postgres_default
76
76
```
77
+
78
+ ## Use with Docker Development Environments
79
+
80
+ You can use this sample with the Dev Environments feature of Docker Desktop.
81
+ To develop directly frontend or the backend services inside containers, you just need to use the https git url of the sample:
82
+ ` https://github.com/docker/awesome-compose/tree/master/react-rust-postgres `
83
+
84
+ ![ page] ( ../dev-envs.png )
You can’t perform that action at this time.
0 commit comments