Skip to content

Commit 13a5ea4

Browse files
committed
🐬Sync with codebase: docker compose
2 parents 02e40ac + d49f20a commit 13a5ea4

10 files changed

Lines changed: 27 additions & 33 deletions

File tree

content/en/docs/a1.hello-world-server.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,13 @@ EXPOSE 8080
182182
> We can use `docker ps` command to see more info. To stop the container `docker stop <name>` and to remove the image `docker rmi -f <image-id>`.
183183
184184

185-
## `docker-compose.yml`
185+
## `compose.yml`
186186

187-
> [📖 Docker Compose](https://docs.docker.com/compose/) is a **tool for defining and running multi-container Docker applications**. With a single command, we can create and start all the services according to the content in the `docker-compose.yml` file. 🔍 If you are new to Docker Compose, I recommend you to read its [**Get Started guild**](https://docs.docker.com/compose/gettingstarted/) on its official documentation.
187+
> [📖 Docker Compose](https://docs.docker.com/compose/) is a **tool for defining and running multi-container Docker applications**. With a single command, we can create and start all the services according to the content in the `compose.yml` file. 🔍 If you are new to Docker Compose, I recommend you to read its [**Get Started guild**](https://docs.docker.com/compose/gettingstarted/) on its official documentation.
188188
189-
Let’s add the `docker-compose.yml`.
189+
Let’s add the `compose.yml`.
190190

191191
```dockerfile
192-
version: '3'
193192
services:
194193

195194
app:
@@ -198,9 +197,9 @@ services:
198197
- "8080:8080"
199198
```
200199

201-
- You can use `docker-compose build` and `docker-compose up` commands, to build and run the application.
200+
- You can use `docker compose build` and `docker compose up` commands, to build and run the application.
202201
- You should see the same response, `Hello, world!` text while visit [localhost:8080/hello](http://localhost:8080/hello) in the browser.
203-
- Use the `docker-compose down` command to stop the application.
202+
- Use the `docker compose down` command to stop the application.
204203

205204

206205
## An idiomatic structure

content/en/docs/a2.database-and-migrations.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ In this article series, we are building a RESTful CRUD API for a simple bookshel
3131

3232
We'll use the [official Postgres Alpine Docker image](https://hub.docker.com/_/postgres) to build our development database.
3333

34-
Let's update the `docker-compose.yml` file,
34+
Let's update the `compose.yml` file,
3535

3636
```dockerfile
37-
version: '3'
3837
services:
3938

4039
app:
@@ -55,9 +54,9 @@ services:
5554
restart: always
5655
```
5756

58-
Run `docker-compose down` and `docker-compose up` to rerun the application with the database. Or, you can run `docker-compose up db` to run only the database.
57+
Run `docker compose down` and `docker compose up` to rerun the application with the database. Or, you can run `docker compose up db` to run only the database.
5958

60-
We can use `docker-compose ps` commands to see more info about the running containers.
59+
We can use `docker compose ps` commands to see more info about the running containers.
6160

6261
```
6362
NAME COMMAND SERVICE STATUS PORTS

content/en/docs/a3.configurations.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ slug: "configurations"
1111

1212
## Populate environment variables with Docker
1313

14-
💡 We use `docker-compose` with the [`env_file`](https://docs.docker.com/compose/compose-file/compose-file-v3/#env_file) option to load the environment variables into the development environment. If you are using `docker run`, you can use the [`--env-file` option](https://docs.docker.com/engine/reference/commandline/run/#options) with it.
14+
💡 We use `docker compose` with the [`env_file`](https://docs.docker.com/compose/compose-file/compose-file-v3/#env_file) option to load the environment variables into the development environment. If you are using `docker run`, you can use the [`--env-file` option](https://docs.docker.com/engine/reference/commandline/run/#options) with it.
1515

1616
### 1. Add `.env`
1717

@@ -32,7 +32,7 @@ DB_DEBUG=true
3232

3333
> 💡 `SERVER_DEBUG` and `DB_DEBUG` will be utilized with the application logs and the GORM logs in the future steps.
3434
35-
### 2. update `docker-compose.yml`
35+
### 2. update `compose.yml`
3636

3737
```yml
3838
app:
@@ -44,7 +44,7 @@ DB_DEBUG=true
4444
- db
4545
```
4646
47-
Run `docker-compose down` and `docker-compose up` to populate the environment variables into the development environment.
47+
Run `docker compose down` and `docker compose up` to populate the environment variables into the development environment.
4848

4949

5050
## Adding configs to the API
@@ -202,7 +202,7 @@ func main() {
202202
}
203203
```
204204

205-
Run `docker-compose down`, `docker-compose build` and `docker-compose up` to run the application with the recent changes.
205+
Run `docker compose down`, `docker compose build` and `docker compose up` to run the application with the recent changes.
206206

207207
### 5. Run `go mod tidy`
208208

@@ -213,10 +213,9 @@ When we add a new package and use it, we have to run `go mod tidy` to reorganize
213213

214214
> 💡 Because we hardcoded `localhost` for the database host in the previous article, we encountered the `migrate up: dial tcp 127.0.0.1:3306: connect: connection refused` error with the `./bin/migrate up` command. But, with the current configurations, we should be able to run `./bin/migrate up` inside the docker image with the correct host. So, let's automate running migrations on application startup.
215215
216-
Usually, starting the database takes more time. So, we need to wait until the database is up before running database migrations. For this, we use `docker-compose` `db:`[`healthcheck`](https://docs.docker.com/compose/compose-file/#healthcheck) and `app:`[`depends_on:db:condition`](https://docs.docker.com/compose/compose-file/#depends_on) options.
216+
Usually, starting the database takes more time. So, we need to wait until the database is up before running database migrations. For this, we use `docker compose` `db:`[`healthcheck`](https://docs.docker.com/compose/compose-file/#healthcheck) and `app:`[`depends_on:db:condition`](https://docs.docker.com/compose/compose-file/#depends_on) options.
217217

218218
```yml
219-
version: '3.9'
220219
services:
221220

222221
app:

content/en/docs/a4.routes-and-openapi-specification.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func main() {
150150
When we add a new package and use it, we have to run `go mod tidy` to reorganize the dependencies in the `go.mod` file.
151151

152152

153-
> 💡 You can use the `docker-compose down`, `docker-compose build`, and `docker-compose up` commands, to build and run the API application to test the recent changes. Alternatively, you can configure your IDE to run `cmd/api/main.go` locally, with the required env variables; Ex: [Running applications in the GoLand IDE](https://www.jetbrains.com/help/go/running-applications.html)
153+
> 💡 You can use the `docker compose down`, `docker compose build`, and `docker compose up` commands, to build and run the API application to test the recent changes. Alternatively, you can configure your IDE to run `cmd/api/main.go` locally, with the required env variables; Ex: [Running applications in the GoLand IDE](https://www.jetbrains.com/help/go/running-applications.html)
154154
155155

156156
## Generating OpenAPI specification

0 commit comments

Comments
 (0)