Skip to content

Commit

Permalink
update README and Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
hgiasac committed Feb 20, 2024
1 parent 581f25f commit 3db2c07
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 538 deletions.
13 changes: 11 additions & 2 deletions codegen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ Commands:
Generate schema and implementation for the connector from functions.
```

## Command

### Initialize connector project

The `init` command generates a boilerplate project for connector development from [template](templates/new) with the following folder structure:
Expand All @@ -35,6 +33,13 @@ The `init` command generates a boilerplate project for connector development fro
- `main.go`: the main function that runs the connector CLI.
- `go.mod`: the module file with required dependencies.
- `README.md`: the index README file.
- `Dockerfile`: the build template for Docker image.

The command requires names of connector and module. By default, the tool creates a new folder with the connector name. If you want to customize the path, or generate files in the current folder. use `--output` (`-o`) argument.

```bash
hasura-ndc-go init -n example -m github.com/foo/example -o .
```

### Generate queries and mutations

Expand All @@ -43,6 +48,10 @@ The `generate` command parses code in the `functions` folder, finds functions an
- `schema.generated.json`: the generated connector schema in JSON format.
- `connector.generated.go`: implement `GetSchema`, `Query` and `Mutation` methods with exposed functions.

```bash
hasura-ndc-go generate
```

## How it works

### Functions
Expand Down
19 changes: 19 additions & 0 deletions codegen/templates/new/Dockerfile.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# build context at repo root: docker build -f Dockerfile .
FROM golang:1.22 AS builder

WORKDIR /app
COPY . .
RUN CGO_ENABLED=0 go build -v -o ndc-cli .

# stage 2: production image
FROM gcr.io/distroless/base-debian12:nonroot

# Copy the binary to the production image from the builder stage.
COPY --from=builder /app/ndc-cli /ndc-cli

# Uncomment following env variables if your connector doesn't need configuration
# ENV INLINE_CONFIG=true
# ENV CONFIGURATION="{}"

# Run the web service on container startup.
CMD ["/ndc-cli", "serve"]
139 changes: 0 additions & 139 deletions example/codegen/connector.generated.go

This file was deleted.

55 changes: 0 additions & 55 deletions example/codegen/connector.go

This file was deleted.

50 changes: 0 additions & 50 deletions example/codegen/functions/query.go

This file was deleted.

47 changes: 0 additions & 47 deletions example/codegen/go.mod

This file was deleted.

Loading

0 comments on commit 3db2c07

Please sign in to comment.