Skip to content
This repository has been archived by the owner on Jun 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #37 from MarvinMenzerath/develop
Browse files Browse the repository at this point in the history
v2.2.1
  • Loading branch information
menzerath committed Apr 8, 2017
2 parents 4500230 + 10c8b81 commit 68cf6f8
Show file tree
Hide file tree
Showing 58 changed files with 3,953 additions and 1,342 deletions.
4 changes: 1 addition & 3 deletions .dockerignore
Expand Up @@ -3,9 +3,7 @@

# IDE (IntelliJ IDEA)
.idea/
UpAndRunning2.iml

# Application
config/local*.json
docs/
README.md
docs/
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -25,7 +25,6 @@ _testmain.go

# IDE (IntelliJ IDEA)
.idea/
UpAndRunning2.iml

# Application
config/local*.json
8 changes: 4 additions & 4 deletions Dockerfile
@@ -1,11 +1,11 @@
FROM alpine:3.4
FROM alpine:3.5
MAINTAINER Marvin Menzerath <github@marvin-menzerath.de>

ENV UAR2_IS_DOCKER true

WORKDIR /app/upandrunning2/
COPY . /app/upandrunning2/
RUN chmod +x ./docker/build.sh && sync && ./docker/build.sh

USER uar2
EXPOSE 8080
ENTRYPOINT ["./UpAndRunning2"]
VOLUME /app/upandrunning2/config/
ENTRYPOINT ["./UpAndRunning2"]
20 changes: 10 additions & 10 deletions Godeps/Godeps.json

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

2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2015-2016 Marvin Menzerath
Copyright (c) 2015-2017 Marvin Menzerath

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 12 additions & 2 deletions docker/build.sh
Expand Up @@ -5,16 +5,26 @@
set -x
set -e

# set path
export GOPATH=/tmp/go
export PATH=${PATH}:${GOPATH}/bin

apk -U --no-progress add git go
# install dependencies
apk -U --no-progress add git go build-base ca-certificates

# build application
mkdir -p ${GOPATH}/src/github.com/MarvinMenzerath/
ln -s /app/upandrunning2/ ${GOPATH}/src/github.com/MarvinMenzerath/UpAndRunning2
cd ${GOPATH}/src/github.com/MarvinMenzerath/UpAndRunning2
go get
go build

# remove sources and unnecessary packages
rm -rf $GOPATH
apk --no-progress del git go
apk --no-progress del git go build-base

# create custom user and group
addgroup -g 1777 uar2 && adduser -h /app/upandrunning2/ -H -D -G uar2 -u 1777 uar2

# set rights
chown -R uar2:uar2 /app/upandrunning2/
59 changes: 15 additions & 44 deletions docs/installation/docker.md
@@ -1,62 +1,33 @@
# Docker Guide
[![Docker Version](https://images.microbadger.com/badges/version/marvinmenzerath/upandrunning2.svg)](http://microbadger.com/images/marvinmenzerath/upandrunning2)
[![Docker Layers](https://images.microbadger.com/badges/image/marvinmenzerath/upandrunning2.svg)](http://microbadger.com/images/marvinmenzerath/upandrunning2)

You can use the small and always up-to-date Docker-image from [Docker Hub](https://hub.docker.com/r/marvinmenzerath/upandrunning2/) to deploy UpAndRunning2 quickly and easily.
Internally this image uses a custom user and group (both called `uar2` with an id of `1777`).

## Installation

### Database
Use these commands to create a new volume called `uar2-db-data` and start a new MariaDB-container called `uar2-db`, which stores it's data inside the previously created volume and uses the root-password `topSecretPassword`:
```
docker volume create --name uar2-db-data
docker run -d --name uar2-db -v uar2-db-data:/var/lib/mysql/ -e MYSQL_ROOT_PASSWORD='topSecretPassword' mariadb
```

If you do not want to use a volume to store the databases's data, simply use this command:
```
docker run -d --name uar2-db -e MYSQL_ROOT_PASSWORD='topSecretPassword' mariadb
```
Setup a MySQL-compatible database (for example by using the [MariaDB image](https://hub.docker.com/_/mariadb/)) and make a note of the database credentials.

### UpAndRunning2
Use this command to create and start a new UpAndRunning2-container called `uar2`, which is linked to the previously created `uar2-db`-container and exposes the web-interface and API on the host's port `80`.
Use this command to create and start a new UpAndRunning2-container called `uar2`, which exposes the web-interface and API on the host's port `80`.
Additionally it stores the configuration-files inside the host's `/srv/uar2/config/` directory, which allows you to change certain parameters.
```
docker run -d --name uar2 --link uar2-db:mysql -p 80:8080 marvinmenzerath/upandrunning2
docker run -d --name uar2 -v /srv/uar2/config/:/app/upandrunning2/config/ -p 80:8080 marvinmenzerath/upandrunning2
```

To make use of the mounted config-directory, you need to:
* pull a recent copy of the [`default.json`-file](../../config/default.json)
* create a copy of it called `local.json`
* and make your custom changes in this file

After those changes you need to restart your container using `docker restart uar2`.

## Upgrading
Just remove the old container, pull the new image and deploy a new container. Make sure to add previously set environment-variables.
Just remove the old container, pull the new image and deploy a new container.
```
docker stop uar2
docker rm uar2
docker pull marvinmenzerath/upandrunning2
docker run -d --name uar2 --link uar2-db:mysql -p 80:8080 marvinmenzerath/upandrunning2
```

## Configuration
There are a few things you can configure using environment-variables.
To do so, just add those environment-variables when creating the container like this:
```
docker run -d --name uar2 --link uar2-db:mysql -p 80:8080 -e UAR2_VARIABLE_NAME='CONTENT' marvinmenzerath/upandrunning2
```

### Configurable Settings
* `UAR2_APPLICATION_TITLE` (e.g. `UpAndRunning2`)
* `UAR2_REDIRECTSTOFOLLOW` (e.g. `3`)
* `UAR2_CHECKIFOFFLINE` (e.g. `true`)
* `UAR2_CHECKLIFETIME` (e.g. `31`)
* `UAR2_USEWEBFRONTEND` (e.g. `true`)
* `UAR2_TELEGRAMBOTAPIKEY` (e.g. `123456`)

### Mailer
If you want to use the built-in mailer, you will need to set those environment-variables:
* `UAR2_MAILER_HOST` (e.g. `smtp.mymail.com`)
* `UAR2_MAILER_PORT` (e.g. `587`)
* `UAR2_MAILER_USER` (e.g. `myUser@mymail.com`)
* `UAR2_MAILER_PASSWORD` (e.g. `mySecretPassword`)
* `UAR2_MAILER_FROM` (e.g. `upandrunning2@mymail.com`)

#### Example
```
docker run -d --name uar2 --link uar2-db:mysql -p 80:8080 -e UAR2_MAILER_HOST='smtp.mymail.com' -e UAR2_MAILER_PORT='587' -e UAR2_MAILER_USER='myUser@mymail.com' -e UAR2_MAILER_PASSWORD='mySecretPassword' -e UAR2_MAILER_FROM='upandrunning2@mymail.com' marvinmenzerath/upandrunning2
```
docker run -d --name uar2 -v /srv/uar2/config/:/app/upandrunning2/config/ -p 80:8080 marvinmenzerath/upandrunning2
```
2 changes: 1 addition & 1 deletion docs/installation/install.md
@@ -1,7 +1,7 @@
# Installation
Looking for the Docker Guide? Click [here](docker.md).

* Download and extract all files into a directory.
* Download and extract all files from [a current release](https://github.com/MarvinMenzerath/UpAndRunning2/releases).
* Prepare your MySQL-Server: create a new user and a new database.
* Copy `config/default.json` to `config/local.json` and change this file to your needs.
* Run the application using a systemd-script or just type `./UpAndRunning2`.
Expand Down
45 changes: 0 additions & 45 deletions lib/configuration.go
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"github.com/op/go-logging"
"os"
"strconv"
)

// This the one and only Configuration-object.
Expand Down Expand Up @@ -73,50 +72,6 @@ type StaticConfiguration struct {
func ReadConfigurationFromFile(filePath string) {
ReadDefaultConfiguration("config/default.json")

if os.Getenv("UAR2_IS_DOCKER") == "true" {
logging.MustGetLogger("").Info("Reading Configuration from Environment Variables...")

config.Database.Host = os.Getenv("MYSQL_PORT_3306_TCP_ADDR")
config.Database.User = "root"
config.Database.Password = os.Getenv("MYSQL_ENV_MYSQL_ROOT_PASSWORD")
config.Database.Database = "upandrunning"

config.Application.Title = os.Getenv("UAR2_APPLICATION_TITLE")

i, err := strconv.Atoi(os.Getenv("UAR2_REDIRECTSTOFOLLOW"))
if err == nil {
config.Application.RedirectsToFollow = i
}

b, err := strconv.ParseBool(os.Getenv("UAR2_CHECKIFOFFLINE"))
if err == nil {
config.Application.RunCheckIfOffline = b
}

i, err = strconv.Atoi(os.Getenv("UAR2_CHECKLIFETIME"))
if err == nil {
config.Application.CheckLifetime = i
}

b, err = strconv.ParseBool(os.Getenv("UAR2_USEWEBFRONTEND"))
if err == nil {
config.Application.UseWebFrontend = b
}

config.Notification.Mailer.Host = os.Getenv("UAR2_MAILER_HOST")
i, err = strconv.Atoi(os.Getenv("UAR2_MAILER_PORT"))
if err == nil {
config.Notification.Mailer.Port = i
}
config.Notification.Mailer.User = os.Getenv("UAR2_MAILER_USER")
config.Notification.Mailer.Password = os.Getenv("UAR2_MAILER_PASSWORD")
config.Notification.Mailer.From = os.Getenv("UAR2_MAILER_FROM")

config.Notification.TelegramBotApiKey = os.Getenv("UAR2_TELEGRAMBOTAPIKEY")

return
}

logging.MustGetLogger("").Info("Reading Configuration from File (" + filePath + ")...")

file, _ := os.Open(filePath)
Expand Down
2 changes: 1 addition & 1 deletion main.go
Expand Up @@ -14,7 +14,7 @@ import (
"time"
)

const VERSION = "2.2.0"
const VERSION = "2.2.1"

var goVersion = runtime.Version()
var goArch = runtime.GOOS + "_" + runtime.GOARCH
Expand Down
4 changes: 2 additions & 2 deletions public/css/font-awesome.min.css

Large diffs are not rendered by default.

0 comments on commit 68cf6f8

Please sign in to comment.