You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/a1.hello-world-server.md
+5-6Lines changed: 5 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -181,14 +181,13 @@ EXPOSE 8080
181
181
> 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>`.
182
182
183
183
184
-
## `docker-compose.yml`
184
+
## `compose.yml`
185
185
186
-
> [📖 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.
186
+
> [📖 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.
187
187
188
-
Let’s add the `docker-compose.yml`.
188
+
Let’s add the `compose.yml`.
189
189
190
190
```dockerfile
191
-
version: '3'
192
191
services:
193
192
194
193
app:
@@ -197,9 +196,9 @@ services:
197
196
- "8080:8080"
198
197
```
199
198
200
-
- You can use `docker-compose build` and `docker-compose up` commands, to build and run the application.
199
+
- You can use `dockercompose build` and `dockercompose up` commands, to build and run the application.
201
200
- You should see the same response, `Hello, world!` text while visit [localhost:8080/hello](http://localhost:8080/hello) in the browser.
202
-
- Use the `docker-compose down` command to stop the application.
201
+
- Use the `dockercompose down` command to stop the application.
Copy file name to clipboardExpand all lines: content/en/docs/a2.database-and-migrations.md
+4-5Lines changed: 4 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ slug: "database-and-migrations"
4
4
---
5
5
6
6
> **👨🏫 Before we start...**
7
-
> - We'll run a Postgres database via `docker-compose`.
7
+
> - We'll run a Postgres database via `dockercompose`.
8
8
> - There are a few popular database migration tools in the Go ecosystem, like [`golang-migrate/migrate`](https://github.com/golang-migrate/migrate), [`pressly/goose`](https://github.com/pressly/goose), [GORM migrations](http://gorm.io/docs/migration.html), etc. We selected [`pressly/goose`](https://github.com/pressly/goose) due to its simplicity, lesser resource usage, and customizability. But, instead of using its prebuilt binaries, we'll build a custom binary with static drivers, settings, and more simplified commands.
9
9
> - ⭐ We'll store all `SQL` database migration files in the `migrations` folder in the project root.
10
10
@@ -30,10 +30,9 @@ In this article series, we are building a RESTful CRUD API for a simple bookshel
30
30
31
31
We'll use the [official Postgres Alpine Docker image](https://hub.docker.com/_/postgres) to build our development database.
32
32
33
-
Let's update the `docker-compose.yml` file,
33
+
Let's update the `compose.yml` file,
34
34
35
35
```dockerfile
36
-
version: '3'
37
36
services:
38
37
39
38
app:
@@ -54,9 +53,9 @@ services:
54
53
restart: always
55
54
```
56
55
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.
56
+
Run `dockercompose down` and `dockercompose up` to rerun the application with the database. Or, you can run `dockercompose up db` to run only the database.
58
57
59
-
We can use `docker-compose ps` commands to see more info about the running containers.
58
+
We can use `dockercompose ps` commands to see more info about the running containers.
Copy file name to clipboardExpand all lines: content/en/docs/a3.configurations.md
+6-7Lines changed: 6 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,13 @@ slug: "configurations"
4
4
---
5
5
6
6
> **👨🏫 Before we start...**
7
-
> - Configurations can be stored in a variety of formats, such as `.xml`, `.json`, `.env`, `.yaml`, and `.toml` files, as well as systems like [`etcd`](https://etcd.io/), [AWS Parameter Store](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html), and [GCP Runtime Configurator](https://cloud.google.com/deployment-manager/runtime-configurator/). In this project, we will save the configurations in an `.env` file and use `docker-compose` to load them into the development environment.
7
+
> - Configurations can be stored in a variety of formats, such as `.xml`, `.json`, `.env`, `.yaml`, and `.toml` files, as well as systems like [`etcd`](https://etcd.io/), [AWS Parameter Store](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html), and [GCP Runtime Configurator](https://cloud.google.com/deployment-manager/runtime-configurator/). In this project, we will save the configurations in an `.env` file and use `dockercompose` to load them into the development environment.
8
8
> - Go standard library provides the [`os.Getenv()`](https://golang.org/pkg/os/#Getenv) function to read each environment variable separately. But there are Go libraries such as [`spf13/viper`](https://github.com/spf13/viper), [`kelseyhightower/envconfig`](https://github.com/kelseyhightower/envconfig), [`caarlos0/env`](https://github.com/caarlos0/env), and [`joeshaw/envdecode`](https://github.com/joeshaw/envdecode) to read environment variables in bulk and populate them as a struct. We choose [`joeshaw/envdecode`](https://github.com/joeshaw/envdecode) for this project because it includes validations, zero-dependency, and ease of use.
9
9
10
10
11
11
## Populate environment variables with Docker
12
12
13
-
💡 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.
13
+
💡 We use `dockercompose` 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
14
15
15
### 1. Add `.env`
16
16
@@ -31,7 +31,7 @@ DB_DEBUG=true
31
31
32
32
> 💡 `SERVER_DEBUG` and `DB_DEBUG` will be utilized with the application logs and the GORM logs in the future steps.
33
33
34
-
### 2. update `docker-compose.yml`
34
+
### 2. update `compose.yml`
35
35
36
36
```yml
37
37
app:
@@ -43,7 +43,7 @@ DB_DEBUG=true
43
43
- db
44
44
```
45
45
46
-
Run `docker-compose down` and `docker-compose up` to populate the environment variables into the development environment.
46
+
Run `dockercompose down` and `dockercompose up` to populate the environment variables into the development environment.
47
47
48
48
49
49
## Adding configs to the API
@@ -201,7 +201,7 @@ func main() {
201
201
}
202
202
```
203
203
204
-
Run `docker-compose down`, `docker-compose build` and `docker-compose up` to run the application with the recent changes.
204
+
Run `dockercompose down`, `dockercompose build` and `dockercompose up` to run the application with the recent changes.
205
205
206
206
### 5. Run `go mod tidy`
207
207
@@ -212,10 +212,9 @@ When we add a new package and use it, we have to run `go mod tidy` to reorganize
212
212
213
213
> 💡 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.
214
214
215
-
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.
215
+
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 `dockercompose``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.
Copy file name to clipboardExpand all lines: content/en/docs/a4.routes-and-openapi-specification.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -149,7 +149,7 @@ func main() {
149
149
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.
150
150
151
151
152
-
> 💡 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)
152
+
> 💡 You can use the `dockercompose down`, `dockercompose build`, and `dockercompose 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)
0 commit comments