Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ pipeline:
# deployment to staging environment

build_stg:
image: golang:1.8-alpine3.6
image: golang:1.9-alpine3.7
environment:
- REACT_APP_SERVER_URL="//code-annotation-staging.srcd.run"
- REACT_APP_SERVER_URL=//code-annotation-staging.srcd.run
commands:
- apk --update upgrade
- apk add --no-cache make git curl ca-certificates bash build-base libxml2-dev protobuf nodejs=6.10.3-r1 nodejs-npm
- npm install -g yarn
- make build
- apk add --no-cache
bash make curl git
ca-certificates build-base
libxml2-dev protobuf
yarn
- make prepare-build
- make packages
debug: true
when:
Expand Down
2 changes: 1 addition & 1 deletion .env.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ OAUTH_CLIENT_ID=
OAUTH_CLIENT_SECRET=
JWT_SIGNING_KEY=testing
ENV=dev
DB_CONNECTION=sqlite:///path/to/db.db
DB_CONNECTION=sqlite://internal.db
OAUTH_RESTRICT_ACCESS=
OAUTH_RESTRICT_REQUESTER_ACCESS=
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ before_install:
- nvm install 8
- nvm use 8
- npm install -g yarn
- yarn install -prod false
- touch .env

script:
- make lint-frontend
Expand Down
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
FROM alpine:3.6
FROM alpine:3.7
ADD ./build/bin /bin
ENTRYPOINT ["/bin/code-annotation"]

RUN apk --update upgrade && \
apk add --no-cache ca-certificates

ENTRYPOINT ["/bin/server"]
44 changes: 33 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ DEPENDENCIES = github.com/golang/dep/cmd/dep github.com/jteeuwen/go-bindata

HOST ?= 127.0.0.1
PORT ?= 8080
SERVER_URL ?= //$(HOST):$(PORT)
REACT_APP_SERVER_URL ?= //$(HOST):$(PORT) # frontend uses $(REACT_APP_SERVER_URL) as backend
UI_DOMAIN ?= $(REACT_APP_SERVER_URL) # /oauth-callback redirects to $(UI_DOMAIN)/?token=__TOKEN__

YARN_PRODUCTION ?= true

# Tools
YARN = yarn
Expand All @@ -14,32 +17,42 @@ GOLINT = golint
GOVET = go vet
BINDATA = go-bindata

# ci variables
TRAVIS_BUILD_DIR ?= $(shell pwd)
PKG_OS = linux
DOCKER_OS = linux
DOCKER_ARCH = amd64

# Including ci Makefile
CI_REPOSITORY ?= https://github.com/src-d/ci.git
CI_PATH ?= $(shell pwd)/.ci
MAKEFILE := $(CI_PATH)/Makefile.main
$(MAKEFILE):
@git clone --quiet --depth 1 -b v1 $(CI_REPOSITORY) $(CI_PATH);

-include $(MAKEFILE)

# set enviroment variables from .env file
include .env
export $(shell sed 's/=.*//' .env)
# Set enviroment variables from .env file
ENV ?= .env
-include $(ENV)
export $(shell [ -f "$(ENV)" ] && sed 's/=.*//' $(ENV))


# Frontend

dependencies-frontend-development:
$(MAKE) dependencies-frontend YARN_PRODUCTION=false

dependencies-frontend:
$(YARN) install
$(YARN) install --production=$(YARN_PRODUCTION)

test-frontend: dependencies-frontend
test-frontend: dependencies-frontend-development
$(YARN) test

lint-frontend: dependencies-frontend
lint-frontend: dependencies-frontend-development
$(YARN) lint

build-frontend: dependencies-frontend
REACT_APP_SERVER_URL=$(SERVER_URL) $(YARN) build
$(YARN) build

dev-frontend: dependencies-frontend
$(YARN) start
Expand All @@ -54,9 +67,17 @@ build-backend: dependencies-backend
lint-backend: dependencies-backend
$(GOLINT) ./server/...
$(GOVET) ./server/...

bindata:
$(BINDATA) -o ./server/assets/asset.go -pkg assets build/static/... build/*.json build/*.png build/index.html
$(BINDATA) \
-modtime 1 \
-pkg assets \
-o ./server/assets/asset.go \
build/static/... \
build/*.json \
build/*.png \
build/*.svg \
build/index.html

prepare-build: | build-frontend build-backend bindata

Expand All @@ -68,6 +89,7 @@ gorun:
serve: build-frontend build-backend gorun

.PHONY: dependencies-frontend build-frontend dev-frontend \
dependencies-frontend-development prepare-build \
test-frontend lint-frontend \
dependencies-backend build-backend release-build \
lint-backend bindata \
Expand Down
2 changes: 1 addition & 1 deletion cli/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type appConfig struct {
Host string `envconfig:"HOST"`
Port int `envconfig:"PORT" default:"8080"`
UIDomain string `envconfig:"UI_DOMAIN" default:"http://127.0.0.1:8080"`
DBConn string `envconfig:"DB_CONNECTION" default:"sqlite://./internal.db"`
DBConn string `envconfig:"DB_CONNECTION" default:"sqlite:///var/code-annotation/internal.db"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by default server will fail because /var/code-annotation doesn't exist.
not very user-friendly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're doing prod first that's the expected location we agreed.
We could maybe change the .env.tpl to be:

DB_CONNECTION=sqlite://internal.db

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's what I mean. It's absolutely okay to have /var/code-annotation path as default, but let's keep it simple for developers. Thanks!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 If anybody else wonders, feedback seems to be addressed and default for dev env was changed as requested.

ExportsPath string `envconfig:"EXPORTS_PATH" default:"./exports"`
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"diff2html": "^2.3.3",
"less": "^2.7.3",
"react": "^16.2.0",
"react-app-rewire-less": "^2.1.0",
"react-app-rewired": "^1.4.0",
"react-bootstrap": "^0.32.0",
"react-dom": "^16.2.0",
"react-helmet": "^5.2.0",
Expand All @@ -27,8 +29,6 @@
"jest-fetch-mock": "^1.4.0",
"node-localstorage": "^1.3.0",
"prettier": "^1.10.1",
"react-app-rewire-less": "^2.1.0",
"react-app-rewired": "^1.4.0",
"redux-mock-store": "^1.4.0"
},
"scripts": {
Expand Down
595 changes: 584 additions & 11 deletions server/assets/asset.go

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions src/pages/Export.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,14 @@ class Export extends Component {
<ul>
{this.state.files.map((f, i) => (
<li key={i}>
<a
href="#"
<button
onClick={e => {
e.preventDefault();
api.exportDownload(f);
}}
>
{f}
</a>
</button>
</li>
))}
</ul>
Expand Down