Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbrazier committed Dec 2, 2018
0 parents commit c7e3792
Show file tree
Hide file tree
Showing 52 changed files with 11,659 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*/node_modules
*/vendor
*/data
*/build
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.idea/

npm-debug.log*
yarn-debug.log*
yarn-error.log*
/.env
*.old
/data

35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
############################
# Build api
############################
FROM golang:1.11.2-alpine3.8 AS apibuilder
RUN apk update && apk add --no-cache git dep
COPY api $GOPATH/src/github.com/alexbrazier/go-url/api
WORKDIR $GOPATH/src/github.com/alexbrazier/go-url/api

# install the dependencies without checking for go code
RUN dep ensure -vendor-only

# Build my app
RUN go build -o /go/bin/server

############################
# Build frontend
############################
FROM node:10.14.0-alpine AS frontendbuilder

COPY frontend /app
WORKDIR /app

RUN yarn --frozen-lockfile && \
yarn build

############################
# Build actual image
############################
FROM alpine:3.8
# Copy our static executable.
COPY --from=apibuilder /go/bin/server /go/bin/server
COPY --from=frontendbuilder /app/build /go/bin/public
WORKDIR /go/bin
# Run the hello binary.
ENTRYPOINT ["/go/bin/server"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Alex Brazier

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
SHELL := /bin/bash

APP_NAME=go-url
CWD=${shell pwd}/
API_DIR=$(CWD)/api
FRONTEND_DIR=$(CWD)/frontend

install:
cd $(API_DIR) && \
dep ensure && \
cd $(FRONTEND_DIR) && \
yarn && \
cd $(CWD)

start-api:
cd $(API_DIR) && \
go run server.go

start-frontend:
cd $(FRONTEND_DIR) && \
yarn start

build-local:
cd $(API_DIR) && go build server.go && \
cd $(FRONTEND_DIR) && yarn build && \
cd $(CWD) && \

build:
docker build -t $(APP_NAME) .
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Go URL

A simple URL shortener written in Go with a React frontend and MongoDB database

# Features

- Shorten urls based on a user defined key
- Alias a key to point to another short url
- Open multiple pages at once by separating keys with a comma
- Alias a key to point to multiple other keys
- Opensearch integration to provide suggestions directly to browser
- Frontend to view most popular searches and search to find existing links
- Frontend to allow anyone to add and edit links
- Optional authentication using Azure AD

# Getting Started

The app uses Makefiles. To build the docker image run `make build`.

Before starting the app for the first time run `make install`, then:
- To start the api run `make start-api`.
- To start the frontend run `make start-frontend`


## Enviroment Configuration

### Authentication
```bash
# Enable Azure auth or not - if enabled, all other fields must be filled in
ENABLE_AUTH=false
# These come from the Azure AD dashboard
AD_TENANT_ID=
AD_CLIENT_ID=
AD_CLIENT_SECRET=
# Secret session token to store the user sessions
SESSION_TOKEN=
```

### Other
```bash
PORT=1323
DEBUG=false
JSON_LOGS=false
# List of addresses for mongo to connect to, e.g. localhost:27017,other
MONGO_ADDRESSES=localhost
MONGO_DATABASE=go
MONGO_USER=
MONGO_PASS=
```
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.1
19 changes: 19 additions & 0 deletions api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Go ###
# Binaries for programs and plugins
*.exe
*.dll
*.so
*.dylib

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

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

# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
.glide/
/vendor

/data
server
193 changes: 193 additions & 0 deletions api/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c7e3792

Please sign in to comment.