diff --git a/content/language/dotnet/deploy.md b/content/language/dotnet/deploy.md index 7aa41086a3..d475aa3121 100644 --- a/content/language/dotnet/deploy.md +++ b/content/language/dotnet/deploy.md @@ -24,7 +24,7 @@ In your `docker-dotnet-sample` directory, create a file named `docker-dotnet-kubernetes.yaml`. Open the file in an IDE or text editor and add the following contents. Replace `DOCKER_USERNAME/REPO_NAME` with your Docker username and the name of the repository that you created in [Configure CI/CD for -your.NET application](configure-ci-cd.md). +your .NET application](configure-ci-cd.md). ```yaml apiVersion: apps/v1 diff --git a/content/language/dotnet/develop.md b/content/language/dotnet/develop.md index 6209164a25..d59fcfaf0f 100644 --- a/content/language/dotnet/develop.md +++ b/content/language/dotnet/develop.md @@ -80,7 +80,7 @@ Uncomment the database instructions in the `compose.yaml` file. The following is the updated `compose.yaml` file. -```yaml +```yaml {hl_lines="8-33"} services: server: build: @@ -236,7 +236,7 @@ Use Compose Watch to automatically update your running Compose services as you e Open your `compose.yaml` file in an IDE or text editor and then add the Compose Watch instructions. The following is the updated `compose.yaml` file. -```yaml +```yaml {hl_lines="11-14"} services: server: build: @@ -305,7 +305,7 @@ Add a new development stage to your Dockerfile and update your `compose.yaml` fi The following is the updated Dockerfile. -```Dockerfile +```Dockerfile {hl_lines="10-13"} # syntax=docker/dockerfile:1 FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build @@ -338,7 +338,7 @@ ENTRYPOINT ["dotnet", "myWebApp.dll"] The following is the updated `compose.yaml` file. -```yaml +```yaml {hl_lines="5"} services: server: build: diff --git a/content/language/dotnet/run-tests.md b/content/language/dotnet/run-tests.md index f663e21e7e..7133d5f80c 100644 --- a/content/language/dotnet/run-tests.md +++ b/content/language/dotnet/run-tests.md @@ -42,7 +42,7 @@ To run your tests when building, you need to update your Dockerfile. You can cre The following is the updated Dockerfile. -```dockerfile +```dockerfile {hl_lines="9"} # syntax=docker/dockerfile:1 FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build diff --git a/content/language/nodejs/develop.md b/content/language/nodejs/develop.md index bf9e8d9fbf..6c2b6a16e9 100644 --- a/content/language/nodejs/develop.md +++ b/content/language/nodejs/develop.md @@ -36,19 +36,19 @@ You need to update the following items in the `compose.yaml` file: The following is the updated `compose.yaml` file. -```yaml +```yaml {hl_lines="7-40"} services: server: build: context: . + ports: + - 3000:3000 environment: NODE_ENV: production POSTGRES_HOST: db POSTGRES_USER: postgres POSTGRES_PASSWORD_FILE: /run/secrets/db-password POSTGRES_DB: example - ports: - - 3000:3000 depends_on: db: condition: service_healthy @@ -148,7 +148,7 @@ development, you can use one multi-stage Dockerfile for both. Update your Dockerfile to the following multi-stage Dockerfile. -```dockerfile +```dockerfile {hl_lines="5-26"} # syntax=docker/dockerfile:1 ARG NODE_VERSION=18.0.0 @@ -167,7 +167,6 @@ COPY . . CMD npm run dev FROM base as prod -ENV NODE_ENV production RUN --mount=type=bind,source=package.json,target=package.json \ --mount=type=bind,source=package-lock.json,target=package-lock.json \ --mount=type=cache,target=/root/.npm \ @@ -178,9 +177,9 @@ CMD node src/index.js ``` In the Dockerfile, you first add a label `as base` to the `FROM -node:${NODE_VERSION}-alpine` statement. This allows you to refer to this build -stage in other build stages. Next, you add a new build stage labeled `dev` to -install your dev dependencies and start the container using `npm run dev`. +node:${NODE_VERSION}-alpine` statement. This lets you refer to this build stage +in other build stages. Next, you add a new build stage labeled `dev` to install +your development dependencies and start the container using `npm run dev`. Finally, you add a stage labeled `prod` that omits the dev dependencies and runs your application using `node src/index.js`. To learn more about multi-stage builds, see [Multi-stage builds](../../build/building/multi-stage.md). @@ -189,8 +188,8 @@ Next, you'll need to update your Compose file to use the new stage. ### Update your Compose file for development -To run the `dev` stage with Compose, you need to update your `compose.yaml` file. -Open your `compose.yaml` file in an IDE or text editor, and then add the +To run the `dev` stage with Compose, you need to update your `compose.yaml` +file. Open your `compose.yaml` file in an IDE or text editor, and then add the `target: dev` instruction to target the `dev` stage from your multi-stage Dockerfile. @@ -200,21 +199,21 @@ Lastly, publish port `9229` for debugging. The following is the updated Compose file. -```yaml +```yaml {hl_lines=[5,8,20,21]} services: server: build: context: . target: dev + ports: + - 3000:3000 + - 9229:9229 environment: NODE_ENV: production POSTGRES_HOST: db POSTGRES_USER: postgres POSTGRES_PASSWORD_FILE: /run/secrets/db-password POSTGRES_DB: example - ports: - - 3000:3000 - - 9229:9229 depends_on: db: condition: service_healthy diff --git a/content/language/nodejs/run-tests.md b/content/language/nodejs/run-tests.md index 605146a1ae..626a1a435a 100644 --- a/content/language/nodejs/run-tests.md +++ b/content/language/nodejs/run-tests.md @@ -79,7 +79,7 @@ To run your tests when building, you need to update your Dockerfile to add a new The following is the updated Dockerfile. -```dockerfile +```dockerfile {hl_lines="27-35"} # syntax=docker/dockerfile:1 ARG NODE_VERSION=18.0.0 @@ -98,7 +98,6 @@ COPY . . CMD npm run dev FROM base as prod -ENV NODE_ENV production RUN --mount=type=bind,source=package.json,target=package.json \ --mount=type=bind,source=package-lock.json,target=package-lock.json \ --mount=type=cache,target=/root/.npm \ diff --git a/content/language/python/develop.md b/content/language/python/develop.md index e6e4978b55..34cec6c49a 100644 --- a/content/language/python/develop.md +++ b/content/language/python/develop.md @@ -55,7 +55,7 @@ In the `compose.yaml` file, you need to uncomment all of the database instructio The following is the updated `compose.yaml` file. -```yaml +```yaml {hl_lines="7-36"} services: server: build: @@ -157,7 +157,7 @@ Watch](../../compose/file-watch.md). Open your `compose.yaml` file in an IDE or text editor and then add the Compose Watch instructions. The following is the updated `compose.yaml` file. -```yaml +```yaml {hl_lines="14-17"} services: server: build: diff --git a/content/language/rust/develop.md b/content/language/rust/develop.md index 10e289cff7..313384e881 100644 --- a/content/language/rust/develop.md +++ b/content/language/rust/develop.md @@ -14,7 +14,7 @@ description: Learn how to develop your Rust application locally. In this section, you’ll learn how to use volumes and networking in Docker. You’ll also use Docker to build your images and Docker Compose to make everything a whole lot easier. -First, you’ll take a look at running a database in a container and how you can use volumes and networking to persist your data and allow your application to talk with the database. Then you’ll pull everything together into a Compose file which allows you to set up and run a local development environment with one command. +First, you’ll take a look at running a database in a container and how you can use volumes and networking to persist your data and let your application talk with the database. Then you’ll pull everything together into a Compose file which lets you set up and run a local development environment with one command. ## Run a database in a container @@ -34,7 +34,7 @@ Now create a network that your application and database will use to talk to each $ docker network create postgresnet ``` -Now you can run PostgreSQL in a container and attach to the volume and network that you created above. Docker pulls the image from Hub and runs it for you locally. +Now you can run PostgreSQL in a container and attach to the volume and network that you created previously. Docker pulls the image from Hub and runs it for you locally. In the following command, option `--mount` is for starting the container with a volume. For more information, see [Docker volumes](../../storage/volumes.md). ```console @@ -99,7 +99,7 @@ For the sample application, you'll use a variation of the backend from the react `docker init` handled creating most of the instructions in the Dockerfile, but you'll need to update it for your unique application. In addition to a `src` directory, this application includes a `migrations` directory to initialize the database. Add a bind mount for the `migrations` directory to the build stage in the Dockerfile. The following is the updated Dockerfile. - ```dockerfile + ```dockerfile {hl_lines="28"} # syntax=docker/dockerfile:1 # Comments are provided throughout this file to help you get started. @@ -219,7 +219,7 @@ You need to update the following items in the `compose.yaml` file: The following is the updated `compose.yaml` file. -```yaml +```yaml {hl_lines=["17-23","30-55"]} # Comments are provided throughout this file to help you get started. # If you need more help, visit the Docker compose reference guide at # https://docs.docker.com/compose/compose-file/ diff --git a/content/language/rust/run-containers.md b/content/language/rust/run-containers.md index 285cf98698..e6d344f65a 100644 --- a/content/language/rust/run-containers.md +++ b/content/language/rust/run-containers.md @@ -75,7 +75,7 @@ ce02b3179f0f10085db9edfccd731101868f58631bdf918ca490ff6fd223a93b Docker started your container in the background and printed the Container ID on the terminal. -Again, make sure that our container is running properly. Run the same curl command from above. +Again, make sure that your container is running properly. Run the curl command again. ```console $ curl http://localhost:3001 @@ -153,7 +153,7 @@ CONTAINER ID IMAGE COMMAND CREATED Notice that the container you just restarted has been started in detached mode. Also, observe the status of the container is "Up X seconds". When you restart a container, it starts with the same flags or commands that it was originally started with. -Now, stop and remove all of your containers and take a look at fixing the random naming issue. Stop the container you just started. Find the name of your running container and replace the name in the command below with the name of the container on your system. +Now, stop and remove all of your containers and take a look at fixing the random naming issue. Stop the container you just started. Find the name of your running container and replace the name in the following command with the name of the container on your system. ```console $ docker stop wonderful_kalam