diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..b781c6ab --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +log +tmp +.bundle +doc +.git +.gitignore +README.md +DOCKER_README.md +ROADMAP.md +CHANGELOG.md +.dockerignore diff --git a/Dockerfile.alpine b/Dockerfile.alpine new file mode 100644 index 00000000..8dca3e02 --- /dev/null +++ b/Dockerfile.alpine @@ -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"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..d9432814 --- /dev/null +++ b/docker-compose.yml @@ -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: {} diff --git a/docker-up.sh b/docker-up.sh new file mode 100755 index 00000000..34984ff5 --- /dev/null +++ b/docker-up.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +bundle exec rake staytus:install staytus:upgrade +bundle exec foreman start