https://github.com/clementlecorre/api-rest-docker
Deploy docker container with Go rest api
https://github.com/clementlecorre/api-rest-docker
api api-rest devops docker golang
Last synced: about 1 year ago
JSON representation
Deploy docker container with Go rest api
- Host: GitHub
- URL: https://github.com/clementlecorre/api-rest-docker
- Owner: clementlecorre
- License: mit
- Created: 2016-12-21T21:41:09.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-16T13:32:59.000Z (almost 9 years ago)
- Last Synced: 2025-01-27T06:32:36.130Z (about 1 year ago)
- Topics: api, api-rest, devops, docker, golang
- Language: Go
- Homepage: http://cl3m3nt.me/api-rest-docker/
- Size: 2.18 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# api-rest-docker
[](https://hub.docker.com/r/cl3m3nt/api-rest-docker/)
[](https://hub.docker.com/r/cl3m3nt/api-rest-docker/)
[](https://hub.docker.com/r/cl3m3nt/api-rest-docker/)
Deploy docker container with Go rest api
## Library used
* https://github.com/yhat/go-docker
* https://github.com/gorilla/mux
## Environment variables
| Variabe | Value | Description |
| ------- |:------|:------------|
| `xtoken` | 1234 | xToken API |
## Run
```bash
docker build -t cl3m3nt/api-rest-docker .
docker run -it -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock -e xtoken=0000 cl3m3nt/api-rest-docker
```
## Deploy with API
```bash
curl -X POST --header 'Content-Type: application/json' --header 'X-AUTH-TOKEN: 0000' -d '{
"Image": "httpd:alpine",
"ExposedPorts": {
"80/tcp" : {}
},
"HostConfig":{
"PortBindings": {
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "80"
}
]
}
},
"Hostname": "coucou",
"Env": [
"test=coucou"
]
}' http://localhost:8080/deploy
```
```bash
curl -X POST --header 'Content-Type: application/json' --header 'X-AUTH-TOKEN: 1234' -d '{
"Image": "nginx",
"Env": [
"VIRTUAL_NETWORK=nginx-proxy",
"LETSENCRYPT_HOST=test.mydomain.com",
"LETSENCRYPT_EMAIL=clement@mydomain.com",
"VIRTUAL_HOST=test.mydomain.com",
"VIRTUAL_PORT=80"
],
"HostConfig":{
"PortBindings": {}
}
"Hostname": "test"
}' http://localhost:8080/deploy
```