diff --git a/react-express-mongodb/README.md b/react-express-mongodb/README.md index 7a30be9..2f896e7 100644 --- a/react-express-mongodb/README.md +++ b/react-express-mongodb/README.md @@ -132,3 +132,14 @@ __Explanation of service mongo__ :key: `If you wish to check your DB changes on your local machine as well. You should have installed MongoDB locally, otherwise you can't access your mongodb service of container from host machine.` :white_check_mark: You should check your __mongo__ version is same as used in image. You can see the version of __mongo__ image in `docker-compose `file, I used __image: mongo:4.2.0__. If your mongo db version on your machine is not same then furst you have to updated your local __mongo__ version in order to works correctly. + +## Use with Docker Development Environments + +You can use this sample with the Dev Environments feature of Docker Desktop. + +![Screenshot of creating a Dev Environment in Docker Desktop](../dev-envs.png) + +To develop directly on the services inside containers, use the HTTPS Git url of the sample: +``` +https://github.com/docker/awesome-compose/tree/master/react-express-mongodb +``` diff --git a/react-express-mysql/.docker/docker-compose.yaml b/react-express-mysql/.docker/docker-compose.yaml new file mode 100644 index 0000000..ec30529 --- /dev/null +++ b/react-express-mysql/.docker/docker-compose.yaml @@ -0,0 +1,64 @@ +services: + backend: + build: + args: + - NODE_ENV=development + context: backend + target: dev-envs + command: npm run start-watch + environment: + - DATABASE_DB=example + - DATABASE_USER=root + - DATABASE_PASSWORD=/run/secrets/db-password + - DATABASE_HOST=db + - NODE_ENV=development + ports: + - 80:80 + - 9229:9229 + - 9230:9230 + secrets: + - db-password + volumes: + - /var/run/docker.sock:/var/run/docker.sock + networks: + - public + - private + depends_on: + - db + db: + # We use a mariadb image which supports both amd64 & arm64 architecture + image: mariadb:10.6.4-focal + # If you really want to use MySQL, uncomment the following line + #image: mysql:8.0.27 + command: '--default-authentication-plugin=mysql_native_password' + restart: always + secrets: + - db-password + volumes: + - db-data:/var/lib/mysql + networks: + - private + environment: + - MYSQL_DATABASE=example + - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db-password + frontend: + build: + context: frontend + target: dev-envs + ports: + - 3000:3000 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + networks: + - public + depends_on: + - backend +networks: + public: + private: +volumes: + back-notused: + db-data: +secrets: + db-password: + file: db/password.txt diff --git a/react-express-mysql/README.md b/react-express-mysql/README.md index 3db38a9..2f87ab2 100644 --- a/react-express-mysql/README.md +++ b/react-express-mysql/README.md @@ -106,5 +106,5 @@ You can use this sample with the Dev Environments feature of Docker Desktop. To develop directly on the services inside containers, use the HTTPS Git url of the sample: ``` -https://github.com/docker/awesome-compose/tree/master/react-express-mongodb +https://github.com/docker/awesome-compose/tree/master/react-express-mysql ``` diff --git a/react-express-mysql/backend/Dockerfile b/react-express-mysql/backend/Dockerfile index cf96658..3863650 100755 --- a/react-express-mysql/backend/Dockerfile +++ b/react-express-mysql/backend/Dockerfile @@ -1,5 +1,7 @@ +# syntax=docker/dockerfile:1.4 + # if you're doing anything beyond your local machine, please pin this to a specific version at https://hub.docker.com/_/node/ -FROM node:lts +FROM node:lts AS development # set our node environment, either development or production # defaults to production, compose overrides this to development on build and run @@ -29,3 +31,17 @@ COPY . /code # using node here is still more graceful stopping then npm with --init afaik # I still can't come up with a good production way to run with npm and graceful shutdown CMD [ "node", "src/index.js" ] + +FROM development as dev-envs +RUN <