Skip to content
This repository was archived by the owner on Aug 1, 2020. It is now read-only.

Commit 0c58dc2

Browse files
committed
Using neelance/graphql-go
1 parent 287541b commit 0c58dc2

File tree

13 files changed

+76
-3205
lines changed

13 files changed

+76
-3205
lines changed

.gitlab-ci.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,16 @@ stages:
77
stage: test-build
88
script:
99
- apk add --no-cache build-base git bash
10-
- go get -d gitlab.com/klud/graphql-docker-api/cmd/gql-dkr
11-
- cd /go/src/gitlab.com/klud/graphql-docker-api/cmd/gql-dkr
10+
- mkdir -p /go/src/gitlab.com/klud/graphql-docker-api/
11+
- cp -r ./ /go/src/gitlab.com/klud/graphql-docker-api/
12+
- cd /go/src/gitlab.com/klud/graphql-docker-api/cmd/gdapi
1213
- go get -d ./
13-
- cd /go/src/github.com/mastertinner
14-
- rm -rf handler
15-
- git clone -b feature/graphiql https://github.com/mastertinner/handler.git
16-
- cd -
1714
- CGO_ENABLED=0 GOOS=linux go build -a -ldflags="-s -w" -installsuffix cgo
15+
- cp -a gdapi /builds/klud/graphql-docker-api/
1816
artifacts:
1917
name: "$CI_JOB_NAME"
2018
paths:
21-
- go/src/gitlab.com/klud/graphql-docker-api/cmd/gql-dkr/gql-dkr
19+
- /builds/klud/graphql-docker-api/gdapi
2220
expire_in: 1 week
2321

2422
.images: &images

Dockerfile

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,12 @@ RUN apk add --no-cache git build-base && \
55
echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
66
apk add --no-cache upx
77
ADD . /go/src/gitlab.com/klud/graphql-docker-api/
8-
WORKDIR /go/src/gitlab.com/klud/graphql-docker-api/cmd/gql-dkr
8+
WORKDIR /go/src/gitlab.com/klud/graphql-docker-api/cmd/gdapi
99
RUN go get -d ./ && \
10-
# Tweaking binary build process, until github.com/mastertinner/handler changes are merged
11-
cd /go/src/github.com/mastertinner && \
12-
rm -rf handler && \
13-
git clone -b feature/graphiql https://github.com/mastertinner/handler.git && \
14-
cd - && \
15-
# Tweaking binary build process, until github.com/mastertinner/handler changes are merged
1610
CGO_ENABLED=0 GOOS=linux go build -a -ldflags="-s -w" -installsuffix cgo && \
17-
# upx --best -qq gql-dkr && \
18-
upx --ultra-brute -qq gql-dkr && \
19-
upx -t gql-dkr
11+
# upx --best -qq gdapi && \
12+
upx --ultra-brute -qq gdapi && \
13+
upx -t gdapi
2014

2115
FROM scratch
2216
# Build-time metadata as defined at http://label-schema.org
@@ -37,6 +31,6 @@ ENV API_ENDPOINT="" \
3731
DOCKER_HOST="" \
3832
GQL_PORT="" \
3933
GRAPHIQL=""
40-
COPY --from=build-env /go/src/gitlab.com/klud/graphql-docker-api/cmd/gql-dkr/gql-dkr .
34+
COPY --from=build-env /go/src/gitlab.com/klud/graphql-docker-api/cmd/gdapi/gdapi .
4135
EXPOSE 8080
42-
CMD ["/gql-dkr"]
36+
CMD ["/gdapi"]

Gopkg.lock

Lines changed: 15 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
# Note!!!
2+
3+
Since this project is in very early stage and due to [graphql-go/graphql](https://github.com/graphql-go/graphql)'s **overwhelming verbosity** the project is migrating to [neelance/graphql-go](https://github.com/neelance/graphql-go), which is more idiomatic and easy to use. ***This branch is gonna be used for such purposes.***
4+
15
# GraphQL Docker API
26

3-
[![pipeline status](https://gitlab.com/klud/graphql-docker-api/badges/master/pipeline.svg)](https://gitlab.com/klud/graphql-docker-api/commits/master) [![](https://images.microbadger.com/badges/version/klud/docker-gql.svg)](https://microbadger.com/images/klud/docker-gql "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/klud/docker-gql.svg)](https://microbadger.com/images/klud/docker-gql "Get your own image badge on microbadger.com") [![Go Report Card](https://goreportcard.com/badge/gitlab.com/klud/graphql-docker-api)](https://goreportcard.com/report/gitlab.com/klud/graphql-docker-api) [![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](LICENSE)
7+
[![pipeline status](https://gitlab.com/klud/graphql-docker-api/badges/migrate-lib/pipeline.svg)](https://gitlab.com/klud/graphql-docker-api/commits/migrate-lib) [![Go Report Card](https://goreportcard.com/badge/gitlab.com/klud/graphql-docker-api)](https://goreportcard.com/report/gitlab.com/klud/graphql-docker-api) [![](https://images.microbadger.com/badges/version/klud/docker-gql:0.1.0-rc.svg)](https://microbadger.com/images/klud/docker-gql:0.1.0-rc "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/klud/docker-gql:0.1.0-rc.svg)](https://microbadger.com/images/klud/docker-gql:0.1.0-rc "Get your own image badge on microbadger.com") [![Docker Pulls](https://img.shields.io/docker/pulls/klud/docker-gql.svg)](https://hub.docker.com/r/klud/docker-gql/) [![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](LICENSE)
48

5-
<p align="center"> <img src="resources/docker-go-graphql.png" alt="Logo" width="400"></p>
9+
![Logo](resources/docker-go-graphql_400.png)
610

711
> A GraphQL Server for the Docker API, written in Golang.
812
@@ -11,16 +15,16 @@
1115
* Schema files can be found [here](resources/schema).
1216
* You can check the query-ready fields in the [TODO list](#todo)
1317

14-
**Note**: It's important to keep this schema synced with the types implemented in the wrapper, best efforts are made in order to keep it so. That being said, You need to know *this schema is subject to change* as the time goes by and new changes are introduced in the Docker API and this wrapper as well.
18+
**Note**: It's important to keep this schema synced with the types implemented in the wrapper, best efforts are made in order to keep it so. That being said, You need to know ***this schema is subject to change*** as the time goes by and new changes are introduced in the Docker API and this wrapper as well.
1519

1620
## Getting Started
1721

1822
### Building from source
1923

20-
* Get the package: `go get -d gitlab.com/klud/graphql-docker-api/cmd/gql-dkr`
24+
* Get the package: `go get -d gitlab.com/klud/graphql-docker-api/cmd/gdapi`
2125
* Dependencies
22-
* **Not using [`dep`](README.md#open-source-libraries-and-tools).** Go to the project folder with `cd $GOPATH/src/gitlab.com/klud/graphql-docker-api/cmd/gql-dkr` and `go get -d ./`, this will download the depedencies needed, once that's done build the package with `go build`.
23-
* **Using [`dep`](README.md#open-source-libraries-and-tools).** Go to the project folder with `cd $GOPATH/src/gitlab.com/klud/graphql-docker-api`, and run `dep install`, now get to `$GOPATH/src/gitlab.com/klud/graphql-docker-api/cmd/gql-dkr` and build the package with `go build`.
26+
* **Not using [`dep`](README.md#open-source-libraries-and-tools).** Go to the project folder with `cd $GOPATH/src/gitlab.com/klud/graphql-docker-api/cmd/gdapi` and `go get -d ./`, this will download the depedencies needed, once that's done build the package with `go build`.
27+
* **Using [`dep`](README.md#open-source-libraries-and-tools).** Go to the project folder with `cd $GOPATH/src/gitlab.com/klud/graphql-docker-api`, and run `dep install`, now get to `$GOPATH/src/gitlab.com/klud/graphql-docker-api/cmd/gdapi` and build the package with `go build`.
2428

2529
**That's pretty much it. Congrats You have GraphQL Docker API on your system now.**
2630

@@ -32,7 +36,7 @@
3236
docker run -d \
3337
--name docker-gql \
3438
-p 8080:8080 \
35-
-e API_ENDPOINT="/api" \
39+
-e UI_ENDPOINT="/api" \
3640
-v /var/run/docker.sock:/var/run/docker.sock \
3741
klud/docker-gql
3842
```
@@ -47,7 +51,7 @@ klud/docker-gql
4751
docker run -d \
4852
--name docker-gql \
4953
-p 8080:8080 \
50-
-e API_ENDPOINT="/api" \
54+
-e UI_ENDPOINT="/api" \
5155
-e DOCKER_HOST="http://<host>:<port>" \
5256
klud/docker-gql
5357
```
@@ -58,25 +62,26 @@ klud/docker-gql
5862
docker run -d \
5963
--name docker-gql \
6064
-p 8080:8080 \
61-
-e API_ENDPOINT="/api" \
65+
-e UI_ENDPOINT="/api" \
6266
-e DOCKER_HOST="https://<host>:<port>" \
6367
-v /path/to/folder/containing/the/docker/certs:/etc/docker \
6468
klud/docker-gql
6569
```
6670

6771
## Environment variables
6872

69-
* `API_ENDPOINT`: Endpoint the API will work on (default: `"/graphql"`).
7073
* `DOCKER_CERT_PATH`: When using safe connection to Docker Remote API.
7174
* `DOCKER_HOST`: Host the API will retrieve information from (default: `"/var/run/docker.sock"`).
7275
* `GQL_PORT`: Port the API will listen on (default: `":8080"`).
73-
* `GRAPHIQL`: UI to execute queries in the browser. It's enabled by default, `GRAPHIQL=0` disables it.
76+
* `GRAPHIQL`: It's enabled by default, `GRAPHIQL=0` must be set in order to disable it.
77+
* `UI_ENDPOINT`: Endpoint GraphiQL will work on (default: `"/graphql"`).
7478

7579
### Notes
7680

7781
* If using a Docker Remote API, this must be specified with the either HTTP or HTTPS protocols (e.g,: `DOCKER_HOST="http://<host>:<port>"`).
7882
* When using HTTPS, the TLS certs must be placed in `/etc/docker` or the `/path/to/folder/containing/the/docker/certs` must be mounted under `/etc/docker` inside the running container, and must follow the semantics behind the [DOCKER_CERT_PATH](https://docs.docker.com/engine/security/https/#create-a-ca-server-and-client-keys-with-openssl) env var.
79-
* `GRAPHIQL` can be reached at the `API_ENDPOINT`; disabling is advised when using in production.
83+
* `GRAPHIQL` can be reached at the `UI_ENDPOINT`; disabling is advised when using in production.
84+
* If GraphiQL is disabled, `UI_ENDPOINT` must not be set at all.
8085

8186
## TODO
8287

@@ -105,13 +110,10 @@ klud/docker-gql
105110

106111
## Open-Source libraries and tools
107112

108-
* [Dep](https://github.com/golang/dep) for *vendoring* dependencies
109-
* [Docker Client](https://github.com/moby/moby/tree/master/client)
110-
* [GraphQL](http://graphql.org)
111-
* [Golang](https://golang.org/)
112-
* [Go GraphQL](https://github.com/graphql-go/graphql)
113-
* [Go GraphQL handler](https://github.com/graphql-go/handler)
114-
* [Gorilla handlers](https://github.com/gorilla/handlers)
113+
* [docker/client](https://github.com/moby/moby/tree/master/client)
114+
* [neelance/graphql-go](https://github.com/neelance/graphql-go)
115+
* [gorilla/handlers](https://github.com/gorilla/handlers) for console logging.
116+
* [golang/dep](https://github.com/golang/dep) for *vendoring* dependencies.
115117

116118
---
117119
> Inspired by [rm3l/docker-api-graphql](https://github.com/rm3l/docker-api-graphql)

cmd/gql-dkr/main.go

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)