Skip to content

Refactor into Golang project structure #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sigplot_data_service
dist/
.git/
ui/webapp/node_modules/
sdscache/
4 changes: 2 additions & 2 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/checkout@v2

- name: Build
run: go build -mod vendor -v .
run: make sds

- name: Test
run: go test -v .
run: go test -v tests/
22 changes: 20 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
# SDS-specific
sdscache
go.sum
sigplot-data-service
bindata_assetfs.go
sigplot_data_service

.idea

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
40 changes: 31 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
FROM golang:1.13.8-alpine3.11
FROM node:16-alpine3.13 as jsbuilder

RUN apk add --no-cache nodejs npm make git yarn
WORKDIR /app

WORKDIR /go/src/app
COPY ui/webapp/package.json ./package.json

RUN go get github.com/go-bindata/go-bindata/...
# We want to cache the node_modules directory
RUN npm i

RUN go get github.com/elazarl/go-bindata-assetfs/...
COPY ui/webapp .

COPY . .
RUN npm run build

RUN go get -d -v ./...
FROM golang:1.16-alpine3.13 as gobuilder

RUN rm -f bindata_assetfs.go && make release && go install -tags ui
WORKDIR /opt/sds/app

RUN mkdir logs
# Copy only the Go source files over
COPY cmd .
COPY internal .
COPY ui/sds_ui.go ./ui/
COPY vendor .

# Copy the built JS app from the previous stage
COPY --from=jsbuilder /app/dist ./ui/webapp/dist

# Put everything together
RUN make sds

FROM busybox:1.33.1

WORKDIR /opt/sds

# Copy over the built static binary
COPY --from=gobuilder /opt/sds/sigplot_data_service .

EXPOSE 5055

ENTRYPOINT [ "sigplot-data-service" ]

CMD "-h"
17 changes: 9 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
.PHONY: ui docker release
GOCMD=CGO_ENABLED=0 go
GOFLAGS=-a -ldflags '-w -extldflags "-static"' -mod vendor

all:
go build
.PHONY: ui docker sds

all: ui sds

ui:
@cd ui && yarn install
@cd ui && npm run build
@go-bindata-assetfs -prefix ui -modtime 1480000000 -tags ui ./ui/dist/...
npm --prefix ./ui/webapp install
npm --prefix ./ui/webapp run build

release: ui
go build -tags ui
sds:
$(GOCMD) build $(GOFLAGS) cmd/sds/sigplot_data_service.go

docker:
docker build -t sds:0.7 .
66 changes: 0 additions & 66 deletions bluefile.go

This file was deleted.

9 changes: 9 additions & 0 deletions cmd/sds/sigplot_data_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import (
"github.com/spectriclabs/sigplot-data-service/internal/app"
)

func main() {
app.Run()
}
122 changes: 0 additions & 122 deletions colorMap.go

This file was deleted.

14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module sigplot-data-service
module github.com/spectriclabs/sigplot-data-service

go 1.16

require (
github.com/elazarl/go-bindata-assetfs v1.0.0
github.com/ghodss/yaml v1.0.0 // indirect
github.com/minio/minio-go/v6 v6.0.47
github.com/tkanos/gonfig v0.0.0-20181112185242-896f3d81fadf
gonum.org/v1/gonum v0.6.2
gopkg.in/yaml.v2 v2.2.8 // indirect
github.com/labstack/echo-contrib v0.11.0
github.com/labstack/echo/v4 v4.4.0
github.com/minio/minio-go/v7 v7.0.12
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.7.0
gonum.org/v1/gonum v0.9.3
)
Loading