Skip to content

Commit 20089c7

Browse files
authored
add configuration to use react-nginx sample with Docker Dev Environments feature (#269)
Signed-off-by: Guillaume Lours <[email protected]>
1 parent e458109 commit 20089c7

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
services:
2+
frontend:
3+
build:
4+
context: .
5+
target: dev-envs
6+
container_name: frontend
7+
ports:
8+
- "80:3000"
9+
- "3000:3000"
10+
volumes:
11+
- /var/run/docker.sock:/var/run/docker.sock

react-nginx/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# syntax=docker/dockerfile:1.4
2+
13
# 1. For build React app
24
FROM node:lts AS development
35

@@ -22,6 +24,22 @@ FROM development AS build
2224

2325
RUN npm run build
2426

27+
28+
FROM development as dev-envs
29+
RUN <<EOF
30+
apt-get update
31+
apt-get install -y --no-install-recommends git
32+
EOF
33+
34+
RUN <<EOF
35+
useradd -s /bin/bash -m vscode
36+
groupadd docker
37+
usermod -aG docker vscode
38+
EOF
39+
# install Docker tools (cli, buildx, compose)
40+
COPY --from=gloursdocker/docker / /
41+
CMD [ "npm", "start" ]
42+
2543
# 2. For Nginx setup
2644
FROM nginx:alpine
2745

react-nginx/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,14 @@ Stopping frontend ... done
8686
Removing frontend ... done
8787
Removing network react-nginx_default
8888
```
89+
90+
## Use with Docker Development Environments
91+
92+
You can use this sample with the Dev Environments feature of Docker Desktop.
93+
94+
![Screenshot of creating a Dev Environment in Docker Desktop](../dev-envs.png)
95+
96+
To develop directly on the services inside containers, use the HTTPS Git url of the sample:
97+
```
98+
https://github.com/docker/awesome-compose/tree/master/react-nginx
99+
```

react-nginx/compose.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: "3.7"
21
services:
32
frontend:
43
build:

0 commit comments

Comments
 (0)