-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
307 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# | ||
# Rails Project | ||
# | ||
tmp/* | ||
log/* | ||
*.log | ||
build/ | ||
coverage/ | ||
.git | ||
.gitignore | ||
.bundle | ||
.powder | ||
build.sh | ||
docker-compose.yml | ||
Dockerfile | ||
env-example | ||
|
||
# | ||
# OS X | ||
# | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
# Icon must end with two \r | ||
Icon | ||
# Thumbnails | ||
._* | ||
# Files that might appear on external disk | ||
.Spotlight-V100 | ||
.Trashes | ||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
FROM alpine:3.3 | ||
|
||
MAINTAINER PRX <sysadmin@prx.org> | ||
|
||
RUN echo "http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \ | ||
apk update && apk --update add ca-certificates ruby ruby-irb ruby-json ruby-rake \ | ||
ruby-bigdecimal ruby-io-console libstdc++ tzdata mysql-dev autossh \ | ||
linux-headers libc-dev zlib libxml2 libxslt libffi | ||
|
||
ENV TINI_VERSION v0.9.0 | ||
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini | ||
RUN chmod +x /tini | ||
|
||
ENV RAILS_ENV production | ||
ENV APP_HOME /app | ||
RUN mkdir -p $APP_HOME | ||
WORKDIR $APP_HOME | ||
ADD Gemfile ./ | ||
ADD Gemfile.lock ./ | ||
|
||
RUN apk --update add --virtual build-dependencies build-base ruby-dev openssl-dev \ | ||
zlib-dev libxml2-dev libxslt-dev libffi-dev && \ | ||
gem install -N bundler && \ | ||
cd $APP_HOME ; \ | ||
bundle config --global build.nokogiri "--use-system-libraries" && \ | ||
bundle config --global build.nokogumbo "--use-system-libraries" && \ | ||
bundle config --global build.ffi "--use-system-libraries" && \ | ||
bundle install --jobs 10 --retry 10 && \ | ||
apk del build-dependencies && \ | ||
(find / -type f -iname \*.apk-new -delete || true) && \ | ||
rm -rf /var/cache/apk/* && \ | ||
rm -rf /usr/lib/ruby/gems/*/cache/* && \ | ||
rm -rf /tmp/* /var/tmp/* && \ | ||
rm -rf ~/.gem | ||
|
||
ADD . ./ | ||
RUN chown -R nobody:nogroup /app | ||
USER nobody | ||
|
||
ENTRYPOINT ["/tini", "--", "./bin/application"] | ||
CMD ["web"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/sh | ||
|
||
PROCESS= | ||
CMD_ARGS= | ||
|
||
CmsUsage () { | ||
echo "usage: application [ help | web | migrate | test | -- ]" | ||
} | ||
|
||
CmsParseOpts () { | ||
PROCESS=$1 | ||
shift | ||
CMD_ARGS=$* | ||
} | ||
|
||
CmsTunnelMysql () { | ||
if [[ -n "$SSH_MYSQL_KEY" && -n "$SSH_MYSQL_DEST" ]] ; then | ||
TMPFILE=$(mktemp) | ||
echo -e "$SSH_MYSQL_KEY" > $TMPFILE | ||
autossh -M 0 -f -N -o ServerAliveInterval=30 -o ServerAliveCountMax=3 \ | ||
-o ExitOnForwardFailure=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ | ||
-i $TMPFILE -L 3306:localhost:3306 $SSH_MYSQL_DEST | ||
if [ $? -eq 0 ] ; then | ||
sleep 2 | ||
if nc -z 127.0.0.1 3306 ; then | ||
echo "Tunneling mysql from $SSH_MYSQL_DEST" | ||
else | ||
echo "Unable to establish mysql tunnel!" | ||
exit 1 | ||
fi | ||
else | ||
echo "Mysql tunneling failed" | ||
exit 1 | ||
fi | ||
fi | ||
} | ||
|
||
CmsRun () { | ||
CMD= | ||
if [ "$PROCESS" = "help" ] ; then | ||
CmsUsage | ||
exit | ||
elif [ "$PROCESS" = "web" ] ; then | ||
CmsTunnelMysql | ||
CMD="bundle exec puma -C config/puma.rb" | ||
elif [ "$PROCESS" = "test" ] ; then | ||
CMD="bundle exec rake db:create test:run RAILS_ENV=test" | ||
elif [ "$PROCESS" = "guard" ] ; then | ||
CMD="bundle exec guard" | ||
elif [ "$PROCESS" = "setup" ] ; then | ||
CMD="bundle exec rake -vt db:setup" | ||
elif [ "$PROCESS" = "--" ] ; then | ||
CMD= | ||
else | ||
echo "ERROR: $PROCESS is not a valid command." | ||
CmsUsage | ||
exit | ||
fi | ||
|
||
$CMD $CMD_ARGS | ||
} | ||
|
||
CmsParseOpts $* | ||
CmsRun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.