Skip to content
Snippets Groups Projects
Commit 2e801d8e authored by Cam Saül's avatar Cam Saül
Browse files

Merge branch 'master' into mongo-relative-dates-2000

parents 698e86cd 647bae64
No related branches found
No related tags found
No related merge requests found
Showing
with 507 additions and 71 deletions
......@@ -18,6 +18,7 @@
(catch-api-exceptions 0)
(check 1)
(checkp 1)
(cond-as-> 2)
(cond-let 0)
(conda 0)
(context 2)
......@@ -35,6 +36,7 @@
(expect-with-dataset 1)
(expect-with-datasets 1)
(format-color 2)
(if-sqlserver 0)
(ins 1)
(let-400 1)
(let-404 1)
......
......@@ -35,3 +35,4 @@ OSX/build
/osx-artifacts
OSX/dsa_priv.pem
bin/config.json
bin/release/aws-eb/metabase-aws-eb.zip
# don't use private/SSH remotes (e.x. git@github.com) because they break Heroku deploys
[submodule "OSX/Vendor/INAppStoreWindow"]
path = OSX/Vendor/INAppStoreWindow
url = git@github.com:indragiek/INAppStoreWindow.git
url = https://github.com/indragiek/INAppStoreWindow.git
FROM ubuntu:trusty
# Make sure we are using UTF-8
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true
# install core build tools
RUN apt-get update && \
apt-get install -y openjdk-7-jdk && \
apt-get install -y nodejs && \
apt-get install -y npm && \
apt-get install -y git && \
apt-get install -y wget
ADD https://raw.github.com/technomancy/leiningen/stable/bin/lein /usr/local/bin/lein
RUN chmod 744 /usr/local/bin/lein
# little bit of cleanup so that our build process will work
ENV PATH /usr/local/bin:$PATH
ENV LEIN_ROOT 1
RUN ln -s /usr/bin/nodejs /usr/bin/node
# add the application source to the image
ADD . /app/source
# expose our default runtime port
EXPOSE 3000
# build and then run it
WORKDIR /app/source
ENTRYPOINT ["bash", "-c", "./bin/build && ./bin/start"]
......@@ -658,4 +658,53 @@ specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.
\ No newline at end of file
<http://www.gnu.org/licenses/>.
Additional permission under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or combining it with any of the below libraries (or a modified version of that library), containing parts covered by the terms of any of the below libraries, the licensors of this Program grant you additional permission to convey the resulting work.
cider/cider-nrepl
clojure-complete
clojurewerkz/quartzite
clojurewerkz/support
clout
colorize
com.cemerick/friend
compojure
environ
hiccup
junit
korma
medley
org.clojure/clojure
org.clojure/clojurescript
org.clojure/core.async
org.clojure/core.cache
org.clojure/core.incubator
org.clojure/core.logic
org.clojure/core.match
org.clojure/core.memoize
org.clojure/data.csv
org.clojure/data.json
org.clojure/data.priority-map
org.clojure/java.classpath
org.clojure/java.jdbc
org.clojure/math.numeric-tower
org.clojure/tools.analyzer
org.clojure/tools.analyzer.jvm
org.clojure/tools.logging
org.clojure/tools.macro
org.clojure/tools.namespace
org.clojure/tools.nrepl
org.clojure/tools.reader
org.tcrawley/dynapath
quoin
refactor-nrepl
robert/hooke
scout
slingshot
stencil
swiss-arrows
tigris
instaparse
......@@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.11.3.19</string>
<string>0.12.0.7</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.11.3.19</string>
<string>0.12.0.7</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
......@@ -35,8 +35,13 @@
<key>SUEnableAutomaticChecks</key>
<true/>
<key>SUFeedURL</key>
<string>https://s3-us-west-1.amazonaws.com/metabase-osx-releases/appcast.xml</string>
<string>https://s3.amazonaws.com/downloads.metabase.com/appcast.xml</string>
<key>SUPublicDSAKeyFile</key>
<string>dsa_pub.pem</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5053" systemVersion="13A603" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5053"/>
<plugIn identifier="com.apple.WebKitIBPlugin" version="5053"/>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="8191"/>
<plugIn identifier="com.apple.WebKitIBPlugin" version="8191"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
......@@ -11,7 +12,7 @@
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="SvH-Fm-ua3" customClass="SUUpdater"/>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate">
<connections>
......@@ -162,11 +163,11 @@
</menuItem>
</items>
</menu>
<window title="Metabase" allowsToolTipsWhenApplicationIsInactive="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g" customClass="INAppStoreWindow">
<window allowsToolTipsWhenApplicationIsInactive="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g" customClass="INAppStoreWindow">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="335" y="390" width="1473" height="901"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1418"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<value key="minSize" type="size" width="1000" height="800"/>
<view key="contentView" canDrawConcurrently="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="1473" height="901"/>
......@@ -174,7 +175,6 @@
<subviews>
<webView canDrawConcurrently="YES" translatesAutoresizingMaskIntoConstraints="NO" id="mhE-X5-FF6">
<rect key="frame" x="0.0" y="0.0" width="1473" height="901"/>
<autoresizingMask key="autoresizingMask"/>
<webPreferences key="preferences" defaultFontSize="12" defaultFixedFontSize="12" plugInsEnabled="NO" javaEnabled="NO">
<nil key="identifier"/>
</webPreferences>
......@@ -191,6 +191,9 @@
<constraint firstAttribute="trailing" secondItem="mhE-X5-FF6" secondAttribute="trailing" id="z4U-O6-LWv"/>
</constraints>
</view>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="showsTitle" value="NO"/>
</userDefinedRuntimeAttributes>
</window>
<customView id="Pem-Bq-pDs" userLabel="titleBarView">
<rect key="frame" x="0.0" y="0.0" width="651" height="32"/>
......@@ -198,11 +201,9 @@
<subviews>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="V9v-oH-CLo">
<rect key="frame" x="64" y="0.0" width="523" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="BVV-jo-b9C">
<rect key="frame" x="229" y="8" width="64" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<rect key="frame" x="229" y="8" width="65" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" enabled="NO" sendsActionOnEndEditing="YES" title="Metabase" id="Vvp-PZ-SY5">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
......@@ -211,7 +212,6 @@
</textField>
<button translatesAutoresizingMaskIntoConstraints="NO" id="dZP-Ul-oSB">
<rect key="frame" x="0.0" y="0.0" width="24" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<constraints>
<constraint firstAttribute="width" constant="24" id="6zn-IR-p7a"/>
</constraints>
......@@ -225,7 +225,6 @@
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="5Bt-VB-Dba">
<rect key="frame" x="24" y="0.0" width="24" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<constraints>
<constraint firstAttribute="width" constant="24" id="cZI-NR-ghh"/>
</constraints>
......@@ -239,7 +238,6 @@
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="HAI-2S-GZQ">
<rect key="frame" x="48" y="0.0" width="24" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<constraints>
<constraint firstAttribute="width" constant="24" id="Bk3-9A-EeN"/>
</constraints>
......@@ -265,7 +263,6 @@
</customView>
<button translatesAutoresizingMaskIntoConstraints="NO" id="XfF-w9-qlO">
<rect key="frame" x="627" y="0.0" width="24" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<constraints>
<constraint firstAttribute="width" constant="24" id="O1n-dk-WFr"/>
</constraints>
......
......@@ -2,9 +2,9 @@
# Overview
Metabase is an easy way to generate charts and dashboards, ask simple ad hoc queries without using SQL, and see detailed information about rows in your Database. You can set it up in under 5 minutes, and then give yourself and others a place to ask simple questions and understand the data your application is generating. It is not tied to any specific framework and can be used out of the box with minimal configuration.
Metabase is an easy way to generate charts and dashboards, ask simple ad hoc queries without using SQL, and see detailed information about rows in your Database. You can set it up in under 5 minutes, and then give yourself and others a place to ask simple questions and understand the data your application is generating. It is not tied to any specific framework and can be used out of the box with minimal configuration.
With a bit of tagging and annotation of what the tables and fields in your database mean, it can be used to provide a rich, humanized version analytics server and administration interface.
With a bit of tagging and annotation of what the tables and fields in your database mean, it can be used to provide a rich, humanized version analytics server and administration interface.
For more information check out [www.metabase.com](http://www.metabase.com)
......@@ -15,44 +15,44 @@ Security is very important to us. If discover any issue regarding security, plea
# Installation
You can run Metabase in two primary ways, as a docker container or as a jar.
You can run Metabase in two primary ways, as a docker container or as a jar.
## Docker
To run Metabase via Docker, just type
docker run -d -p 3000:3000 name metabase metabase/metabase:v0.12.0
docker run -d -p 3000:3000 --name metabase metabase/metabase
## JVM Jar
To run the jar you will need to have a Java Runtime installed. As a quick check to see if you system already has one, try
To run the jar you will need to have a Java Runtime installed. As a quick check to see if you system already has one, try
java -version
If you see something like
If you see something like
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
you are good to go. Otherwise, download the Java Runtime Environment at http://java.com/
Go to the [Metabase Download Page](http://www.metabase.com/download) and download the current build. Place the downloaded jar into a newly created directory (as it will create some files when it is run), and run it on the command line:
Go to the [Metabase Download Page](http://www.metabase.com/start/) and download the current build. Place the downloaded jar into a newly created directory (as it will create some files when it is run), and run it on the command line:
java -jar metabase.jar
java -jar metabase.jar
Now, open a browser and go to `http://localhost:3000` , and you will be asked a set of questions that will set up a user account, and then you can add a database connection. For this to work you will need to get some information about which database you want to connect to, such as the Host Name and Port that it is running on, the Database Name and the User and Password that you will be using.
Now, open a browser and go to [http://localhost:3000](http://localhost:3000) , and you will be asked a set of questions that will set up a user account, and then you can add a database connection. For this to work you will need to get some information about which database you want to connect to, such as the Host Name and Port that it is running on, the Database Name and the User and Password that you will be using.
Once you have added this connection, you will be taken into the app and you'll be ready to ask your first question.
Once you have added this connection, you will be taken into the app and you'll be ready to ask your first question.
For a more detailed walkthrough, check out our [Getting Started](docs/getting-started/start.md) guide.
For a more detailed walkthrough, check out our [Getting Started](docs/getting-started.md) guide.
# Contributing
To get started with a development installation of the Query Server and learn more about contributing, please follow the instructions at our [Developers Guide](docs/developers-guide.md).
To get started with a development installation of the Query Server and learn more about contributing, please follow the instructions at our [Developers Guide](docs/developers-guide.md).
# Extending and Deep Integrations
......@@ -65,8 +65,8 @@ Metabase also allows you to hit our Query API directly from Javascript to integr
# License
Unless otherwise noted, all Metabase Report Server source files are made available under the terms of the GNU Affero General Public License (AGPL).
Unless otherwise noted, all Metabase source files are made available under the terms of the GNU Affero General Public License (AGPL).
See individual files for details.
See [LICENSE.txt](https://github.com/metabase/metabase/blob/master/LICENSE.txt) for details and exceptions.
Copyright © 2015 Metabase, Inc
Unless otherwise noted, all files © 2015 Metabase, Inc.
......@@ -11,15 +11,14 @@
"repository": "https://github.com/metabase/metabase",
"logo": "https://avatars3.githubusercontent.com/u/10520629?v=3&s=200",
"success_url": "/setup",
"buildpacks": [
{
"url": "https://github.com/heroku/heroku-buildpack-nodejs"
},
{
"url": "https://github.com/heroku/heroku-buildpack-clojure"
}
],
"env": {
"NPM_CONFIG_LOGLEVEL": "info"
}
},
"addons": [
"heroku-postgresql",
"mailgun"
],
"buildpacks": [
{ "url": "https://github.com/heroku/heroku-buildpack-nodejs" },
{ "url": "https://github.com/heroku/heroku-buildpack-clojure" }
]
}
......@@ -2,6 +2,5 @@
"codesigningIdentity": "Developer ID Application: Metabase, Inc",
"slackWebhookURL": "",
"awsProfile": "metabase",
"awsRegion": "",
"awsBucket": ""
}
#!/bin/bash
curl -H "Content-Type: application/json" -X POST -d '{"docker_tag":"latest"}' $1
......@@ -21,23 +21,30 @@ Readonly my $zipfile => artifact('Metabase.zip');
Readonly my $appcast => artifact('appcast.xml');
Readonly my $release_notes => artifact('release-notes.html');
Readonly my $dmg => artifact('Metabase.dmg');
Readonly my @files_to_upload => ($zipfile, $appcast, $release_notes, $dmg);
Readonly my $xcode_project => get_file_or_die('OSX/Metabase.xcodeproj');
# Get the version saved in the CFBundle, e.g. 0.11.3.1
# Get the version saved in the CFBundle, e.g. '0.11.3.1'
sub version {
return trim(plist_buddy_exec('Print', 'CFBundleVersion'));
}
# Next version after version(), e.g. 0.11.3.2
# Get the tag saved in version.properties, e.g. '0.12.0'
sub version_from_props_file {
open(FILE, get_file_or_die('resources/version.properties')) or die $!;
while (<FILE>) { m/^tag/ && s/^tag=v([0-9.]+)[^0-9.]*$/$1/ && (return trim($_)); };
}
# This is the name of the subdirectory on s3, e.g. 'v.0.12.0'
sub upload_subdir {
return 'v' . version_from_props_file();
}
# Next version after version(), e.g. '0.11.3.2'
sub next_version {
my ($old_version_tag, $old_version_point_release) = (version() =~ /^(\d+\.\d+\.\d+)\.(\d+)$/);
# Get the tag saved in version.properties
my $tag_from_props_file = '';
open(FILE, get_file_or_die('resources/version.properties')) or die $!;
while (<FILE>) { m/^tag/ && s/^tag=v(.+)$/$1/ && ($tag_from_props_file = trim($_)); };
Readonly my $tag_from_props_file => version_from_props_file();
# Now calculate the new version, which is ($tag.$point_release)
# Check and see if tag has changed in version.properties; if so, new version is the first "point release" of that tag.
......@@ -146,7 +153,6 @@ sub generate_appcast {
remove_tree($appcast);
my $aws_region = config('awsRegion') or return;
my $aws_bucket = config('awsBucket') or return;
my $signature = generate_signature() or return;
......@@ -155,8 +161,8 @@ sub generate_appcast {
VERSION => version(),
SIGNATURE => $signature,
LENGTH => stat(get_file_or_die($zipfile))->size,
S3_REGION => $aws_region,
S3_BUCKET => $aws_bucket
S3_BUCKET => $aws_bucket,
S3_SUBDIR => upload_subdir()
});
close $out;
}
......@@ -181,7 +187,7 @@ sub create_dmg_from_source_dir {
'-fs', 'HFS+',
'-fsargs', '-c c=64,a=16,e=16',
'-format', 'UDRW',
'-size', '144MB', # it looks like this can be whatever size we want; compression slims it down
'-size', '256MB', # it looks like this can be whatever size we want; compression slims it down
$dmg_filename) == 0 or die $!;
}
......@@ -290,7 +296,7 @@ sub create_dmg {
sub announce_on_slack {
Readonly my $slack_url => config('slackWebhookURL') or return;
Readonly my $version => version();
Readonly my $awsURL => 'https://s3-' . config('awsRegion') . '.amazonaws.com/' . config('awsBucket') . '/Metabase.dmg';
Readonly my $awsURL => 'https://s3.amazonaws.com/' . config('awsBucket') . '/' . upload_subdir() . '/Metabase.dmg';
my $text = "Metabase OS X $version 'Turbulent Toucan' Is Now Available!\n\n" .
"Get it here: $awsURL\n\n";
......@@ -316,18 +322,31 @@ sub announce_on_slack {
# Make sure to run `aws configure --profile metabase` first to set up your ~/.aws/config file correctly
sub upload {
my $aws_profile = config('awsProfile') or return;
my $aws_region = config('awsRegion') or return;
my $aws_bucket = config('awsBucket') or return;
for my $file (@files_to_upload) {
announce "Uploading $file ...";
system('aws',
'--profile', $aws_profile,
'--region', $aws_region,
's3', 'cp', get_file_or_die($file),
"s3://$aws_bucket") == 0 or die "Upload failed: $!\n";
# Make a folder that contains the files we want to upload
Readonly my $upload_dir => artifact('upload');
remove_tree($upload_dir) if -d $upload_dir;
mkdir $upload_dir or die $!;
# appcast.xml goes in the root directory
copy(get_file_or_die($appcast), $upload_dir) or die $!;
# zipfile, release notes, and DMG go in a dir like v0.12.0
Readonly my $upload_subdir => $upload_dir . '/' . upload_subdir();
mkdir $upload_subdir or die $!;
for my $file ($zipfile, $release_notes, $dmg) {
copy(get_file_or_die($file), $upload_subdir) or die $!;
}
announce "Uploading files to $aws_bucket...";
system('aws', '--recursive',
'--profile', $aws_profile,
'--region', 'us-east-1',
's3', 'cp', $upload_dir,
"s3://$aws_bucket") == 0 or die "Upload failed: $!\n";
announce_on_slack;
announce "Upload finished."
......
......@@ -15,10 +15,11 @@ use Metabase::Util;
use constant JRE_DEST => getcwd() . '/OSX/Metabase/jre';
use constant JRE_HOME => trim(`/usr/libexec/java_home`) . '/jre';
use constant UBERJAR_SRC => getcwd() . '/target/uberjar/metabase-standalone.jar';
use constant UBERJAR_SRC => getcwd() . '/target/uberjar/metabase.jar';
use constant UBERJAR_DEST => getcwd() . '/OSX/Resources/metabase.jar';
use constant ENABLE_JAR_PACKING => 0;
use constant ENABLE_JAR_OPTIONAL_FILE_STRIPPING => 0;
sub remove_jre_optional_files {
my @optional_files = ('bin/keytool',
......@@ -70,7 +71,7 @@ sub pack_jre_jars {
(rcopy(JRE_HOME, JRE_DEST) or die $!) unless -d JRE_DEST;
# Remove optional files from JRE dest
remove_jre_optional_files();
remove_jre_optional_files() if ENABLE_JAR_OPTIONAL_FILE_STRIPPING;
# Pack JARs in JRE if applicable
pack_jar() if ENABLE_JAR_PACKING;
......
######
# Metabase Report server Elastic Beanstalk configuration
# Modify the environmental variables below to customize your installation
# Comment out a variable to disable a feature
#####
container_commands:
#customize_env:
#env:
#NGINX_SERVER_NAME: metabase.example.com
#NGINX_FORCE_SSL: 1
#PAPERTRAIL_HOSTNAME: $HOSTNAME
#PAPERTRAIL_HOST: foobar.papertrailapp.com
#PAPERTRAIL_PORT: 12345
#PAPERTRAIL_FILES: /var/log/nginx/access.log /var/log/nginx/error.log
#command: true
#ignoreErrors: false
01_server-name:
command: ".ebextensions/metabase_config/metabase-setup.sh server_name"
test: test $NGINX_SERVER_NAME
ignoreErrors: true
02_server_https:
command: ".ebextensions/metabase_config/metabase-setup.sh server_https"
test: test $NGINX_FORCE_SSL
ignoreErrors: true
03_log_x_real_ip:
command: ".ebextensions/metabase_config/metabase-setup.sh log_x_real_ip"
ignoreErrors: true
04_install_papertrail:
command: ".ebextensions/metabase_config/metabase-setup.sh install_papertrail"
test: test $PAPERTRAIL_HOST
ignoreErrors: true
05_try_papertrail:
command: "/sbin/service remote_syslog restart"
test: test -e /etc/log_files.yml
ignoreErrors: true
06_try_nginx:
command: "/sbin/service nginx restart"
test: nginx -t
ignoreErrors: false
option_settings:
- namespace: aws:elasticbeanstalk:command
option_name: Timeout
value: 600
#!/bin/bash
####
# Metabase Report server Elastic Beanstalk metabase-setup.sh
# Modify the environmental variables to customize your installation
# Unset a variable to disable a feature
####
# add files to papertrail
pt_files () {
sed -i '/ - .*/d' /etc/log_files.yml
set -f
for file in $PAPERTRAIL_FILES; do
sed -i 's|files:|files:\n - '$file'|' /etc/log_files.yml
done
set +f
}
# papertail remote host
pt_remote_host () {
sed -i "s/.*host:.*/ host: $PAPERTRAIL_HOST/" /etc/log_files.yml
}
# papertail remote port
pt_port () {
sed -i "s/.*port:.*/ port: $PAPERTRAIL_PORT/" /etc/log_files.yml
}
# papertail local host
pt_local_host () {
eval export PAPERTRAIL_HOSTNAME=$PAPERTRAIL_HOSTNAME # expand vars like $HOSTNAME
sed -i "s/.*hostname:.*/hostname: $PAPERTRAIL_HOSTNAME/" /etc/log_files.yml
}
# nginx server name
server_name () {
[[ "$NGINX_SERVER_NAME" ]] && cp_default_server
cd /etc/nginx/sites-available/
if [[ "$NGINX_SERVER_NAME" ]] ; then
if ! grep -q server_name elasticbeanstalk-nginx-docker-proxy.conf ; then
sed -i "s|listen 80\;|listen 80\;\n server_name $NGINX_SERVER_NAME \*\.$NGINX_SERVER_NAME\;\n|" elasticbeanstalk-nginx-docker-proxy.conf
fi
else
# no hostname passed, disable default_server
sed -i '/server_name/d' elasticbeanstalk-nginx-docker-proxy.conf
[[ -e /etc/nginx/sites-enabled/default_server ]] && rm /etc/nginx/sites-enabled/default_server
fi
}
# enable https redirect
server_https () {
cd /etc/nginx/sites-available/
if [[ "$NGINX_FORCE_SSL" ]] && ! grep -q https elasticbeanstalk-nginx-docker-proxy.conf ; then
sed -i 's|location \/ {|location \/ {\n\n if ($http_x_forwarded_proto != "https") {\n rewrite ^ https:\/\/$host$request_uri? permanent;\n }\n|' elasticbeanstalk-nginx-docker-proxy.conf
fi
}
# download, install and configure papertrail
install_papertrail () {
cp .ebextensions/metabase_config/papertrail/log_files.yml /etc/log_files.yml && chmod 644 /etc/log_files.yml
cp .ebextensions/metabase_config/papertrail/remote_syslog /etc/init.d/remote_syslog && chmod 555 /etc/init.d/remote_syslog
cd /tmp/
wget -q "https://github.com/papertrail/remote_syslog2/releases/download/v0.14/remote_syslog_linux_amd64.tar.gz" &&
tar xzf remote_syslog_linux_amd64.tar.gz
/sbin/service remote_syslog stop
mv /tmp/remote_syslog/remote_syslog /usr/local/bin/
rm -rf remote_syslog_linux_amd64.tar.gz remote_syslog
# Setup Papertrail
[[ "$PAPERTRAIL_HOST" ]] && pt_remote_host
[[ "$PAPERTRAIL_PORT" ]] && pt_port
[[ "$PAPERTRAIL_FILES" ]] && pt_files
[[ "$PAPERTRAIL_HOSTNAME" ]] && pt_local_host
}
# enable default_server to drop DNS poisoning
cp_default_server () {
cp .ebextensions/metabase_config/nginx/default_server /etc/nginx/sites-available/default_server
[[ ! -e /etc/nginx/sites-enabled/default_server ]] &&
ln -s /etc/nginx/sites-available/default_server /etc/nginx/sites-enabled/default_server
}
# update nginx logging to include x_real_ip
log_x_real_ip () {
cp .ebextensions/metabase_config/nginx/log_x_real_ip.conf /etc/nginx/conf.d/log_x_real_ip.conf
cd /etc/nginx/sites-available
if ! grep -q access_log *-proxy.conf ; then
sed -i 's|location \/ {|location \/ {\n\n access_log \/var\/log\/nginx\/access.log log_x_real_ip;\n|' *-proxy.conf
fi
}
case $1 in
server_name)
server_name
;;
server_https)
server_https
;;
install_papertrail)
install_papertrail
;;
log_x_real_ip)
log_x_real_ip
;;
esac
# /etc/nginx/sites-available/default_server
server {
listen 80 default_server;
location /api/health {
access_log off;
proxy_pass http://docker;
proxy_http_version 1.1;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location / {
return 444;
}
}
# /etc/nginx/conf.d/log_x_real_ip.conf
log_format log_x_real_ip '$proxy_add_x_forwarded_for - [$time_local] '
'$request $status $body_bytes_sent '
'$http_referer $http_user_agent';
# /etc/log_files.yml - Papertrail
files:
- /var/log/nginx/access.log
hostname:
destination:
host:
port:
protocol: tls
new_file_check_interval: "10" # Check every 10 seconds
#!/bin/bash
# /etc/init.d/remote_syslog
#
# remote_syslog This shell script takes care of starting and stopping
# remote_syslog daemon
#
# chkconfig: - 58 74
# description: papertrail/remote_syslog \
# https://github.com/papertrail/remote_syslog2/blob/master/examples/remote_syslog.init.d
### BEGIN INIT INFO
# Provides: remote_syslog
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Should-Start: $syslog $named ntpdate
# Should-Stop: $syslog $named
# Short-Description: start and stop remote_errolog
# Description: papertrail/remote_syslog2
# https://github.com/papertrail/remote_syslog2/blob/master/examples/remote_syslog.init.d
### END INIT INFO
# Source function library.
. /etc/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
prog="/usr/local/bin/remote_syslog"
config="/etc/log_files.yml"
pid_dir="/var/run"
EXTRAOPTIONS=""
pid_file="$pid_dir/remote_syslog.pid"
PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
RETVAL=0
is_running(){
# Do we have PID-file?
if [ -f "$pid_file" ]; then
# Check if proc is running
pid=`cat "$pid_file" 2> /dev/null`
if [[ $pid != "" ]]; then
exepath=`readlink /proc/"$pid"/exe 2> /dev/null`
exe=`basename "$exepath"`
if [[ $exe == "remote_syslog" ]]; then
# Process is running
return 0
fi
fi
fi
return 1
}
start(){
echo -n $"Starting $prog: "
unset HOME MAIL USER USERNAME
$prog -c $config --pid-file=$pid_file $EXTRAOPTIONS
RETVAL=$?
echo
return $RETVAL
}
stop(){
echo -n $"Stopping $prog: "
if (is_running); then
kill `cat $pid_file`
RETVAL=$?
echo
return $RETVAL
else
echo "$pid_file not found"
fi
}
status(){
echo -n $"Checking for $pid_file: "
if (is_running); then
echo "found"
else
echo "not found"
fi
}
reload(){
restart
}
restart(){
stop
start
}
condrestart(){
is_running && restart
return 0
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
reload)
reload
;;
condrestart)
condrestart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
RETVAL=1
esac
exit $RETVAL
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "metabase/metabase:@@MB_TAG@@",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "3000"
}
],
"Logging": "/var/log/metabase"
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment