Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding docker-compose and alpine based Dockerfile #282

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
log
tmp
.bundle
doc
.git
.gitignore
README.md
DOCKER_README.md
ROADMAP.md
CHANGELOG.md
.dockerignore
25 changes: 25 additions & 0 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM ruby:2.6.3-alpine

RUN apk add --update --no-cache \
build-base \
mariadb-dev \
tzdata \
nodejs \
libc6-compat

RUN adduser -D staytus
WORKDIR /staytus
COPY Gemfile* ./
COPY config/database.example.yml config/database.yml
RUN bundle install --binstubs --without development test
COPY --chown=staytus . .

ARG DATABASE_URL
ENV RAILS_LOG_TO_STDOUT=TRUE
RUN bundle exec rake staytus:build
RUN chown -R staytus:staytus /staytus
USER staytus

EXPOSE 5000

ENTRYPOINT ["./docker-up.sh"]
31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '2'

services:
db:
image: mariadb:10.4
restart: always
environment:
MYSQL_ROOT_PASSWORD: admin
MYSQL_DATABASE: staytus
MYSQL_USER: staytus
MYSQL_PASSWORD: staytus
volumes:
- db_data:/var/lib/mysql

app:
build:
context: .
dockerfile: Dockerfile.alpine
depends_on:
- db
ports:
- 5000:5000
volumes:
- .:/staytus
environment:
DATABASE_URL: "mysql2://staytus:staytus@db/staytus"
RAILS_ENV: production
LOG_LEVEL: DEBUG

volumes:
db_data: {}
4 changes: 4 additions & 0 deletions docker-up.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

bundle exec rake staytus:install staytus:upgrade
bundle exec foreman start