An open API service indexing awesome lists of open source software.

https://github.com/nikoheikkila/golang-docker-api

Example project showing how to develop and package a Golang REST API with Docker.
https://github.com/nikoheikkila/golang-docker-api

docker docker-compose golang rest-api

Last synced: about 1 year ago
JSON representation

Example project showing how to develop and package a Golang REST API with Docker.

Awesome Lists containing this project

README

          

# Golang REST API + Docker Example 🐭🐳📦

This is a brief example project showing how to package a REST API application as a Docker image running a static binary.

## Usage

### Docker Compose

Build the image and launch a container.

```sh
docker-compose up --build -d
docker-compose logs -f
```

Then hit it with requests using your favourite tool and follow the log output.

```sh
curl -x GET http://localhost:3000/users | jq
```

### GitHub Codespaces

1. Open this repository in [github.com](https://github.com/nikoheikkila/golang-docker-api)
2. Press . to launch the GitHub web editor
3. From the bottom-left corner, choose _Continue working on_ and choose _Create New Codespace_
4. Wait for the build to finish, and run `make start` to start the server inside the running container, or `make build` to compile

### VS Code Dev Container

1. Open the repository in VS Code
2. From the remote containers menu in the bottom-left corner, choose _Reopen in container_
3. Repeat step #4 from above