-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Move igor commands into single binary - Adds DB migrate tool - Respeced DB setup into migrations for https://github.com/golang-migrate/migrate - Moved User/Password setting to env vars for easier integration - Fixed flaky unit test
- Loading branch information
Showing
28 changed files
with
518 additions
and
433 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
cmd/db_migrate/*.sql | ||
cmd/db_migrate/00.sql | ||
**/__pycache__ | ||
release.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Build the application | ||
FROM golang:1.21 | ||
|
||
WORKDIR /go/src/github.com/voidshard/igor | ||
COPY go.mod ./ | ||
COPY go.sum ./ | ||
COPY cmd cmd | ||
COPY pkg pkg | ||
COPY internal internal | ||
RUN go mod download | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux go build -o /igor ./cmd/igor/*.go | ||
|
||
# Create a minimal image | ||
FROM alpine | ||
|
||
ARG USER=app | ||
ARG GROUPNAME=$USER | ||
ARG UID=12345 | ||
ARG GID=23456 | ||
|
||
RUN addgroup \ | ||
--gid "$GID" \ | ||
"$GROUPNAME" \ | ||
&& adduser \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--home "$(pwd)" \ | ||
--ingroup "$GROUPNAME" \ | ||
--no-create-home \ | ||
--uid "$UID" \ | ||
$USER | ||
|
||
COPY --from=0 /igor /igor | ||
COPY migrations migrations | ||
RUN chown -R $USER:$GROUPNAME /igor migrations | ||
|
||
USER $USER | ||
ENTRYPOINT ["/igor"] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/voidshard/igor/internal/utils" | ||
"github.com/voidshard/igor/pkg/api" | ||
"github.com/voidshard/igor/pkg/api/http/server" | ||
"github.com/voidshard/igor/pkg/database" | ||
"github.com/voidshard/igor/pkg/queue" | ||
) | ||
|
||
const ( | ||
docApi = `Run the API server` | ||
) | ||
|
||
type optsAPI struct { | ||
optsGeneral | ||
optsDatabase | ||
optsQueue | ||
|
||
Addr string `long:"addr" env:"ADDR" description:"Address to bind to" default:"localhost:8100"` | ||
TLSCert string `long:"cert" env:"CERT" description:"Path to TLS certificate"` | ||
TLSKey string `long:"key" env:"KEY" description:"Path to TLS key"` | ||
|
||
StaticDir string `long:"static-dir" env:"STATIC_DIR" default:"" description:"Serve static files from this directory"` | ||
} | ||
|
||
func (c *optsAPI) Execute(args []string) error { | ||
// This main runs an API server (in this case, http) so that callers can interact with Igor over HTTP. | ||
// Since this is configured with OptionsClientDefault it does not run any background routines | ||
// that Igor needs to function (ie, to process events, queue tasks etc). | ||
// | ||
// This is intended purely to serve Igor's service API to clients over the network. Though you could | ||
// have one server type do both if you wanted. | ||
// | ||
// If you wished to interact with Igor via. importing the pkg libraries, then you don't need to run this. | ||
// | ||
// Alternatively, you could add more servers under pkg/api/ to serve Igor's API over other protocols like | ||
// gRPC, thrift or whatever you like and modifiy this to serve them all. | ||
tlsCfg, err := utils.TLSConfig(c.QueueTLSCaCert, c.QueueTLSCert, c.QueueTLSKey) | ||
if err != nil { | ||
panic(err) | ||
} | ||
qOpts := &queue.Options{URL: c.QueueURL, TLSConfig: tlsCfg} | ||
|
||
api, err := api.New( | ||
&database.Options{URL: c.DatabaseURL}, | ||
qOpts, | ||
api.OptionsClientDefault(), | ||
) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
s := server.NewServer(c.Addr, c.StaticDir, c.TLSCert, c.TLSKey, c.Debug) | ||
return s.ServeForever(api) | ||
} |
Oops, something went wrong.