Skip to content

Commit

Permalink
deloy
Browse files Browse the repository at this point in the history
  • Loading branch information
maearon committed Nov 8, 2022
1 parent 94a37d6 commit d213586
Show file tree
Hide file tree
Showing 49 changed files with 1,754 additions and 356 deletions.
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM ruby:3.1.2

# Install node & yarn
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get install -y nodejs
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install -y yarn

# Install base deps or additional (e.g. tesseract)
ARG INSTALL_DEPENDENCIES
RUN apt-get update -qq \
&& apt-get install -y --no-install-recommends ${INSTALL_DEPENDENCIES} \
build-essential libpq-dev git \
&& apt-get clean autoclean \
&& apt-get autoremove -y \
&& rm -rf \
/var/lib/apt \
/var/lib/dpkg \
/var/lib/cache \
/var/lib/log

# Install deps with bundler
RUN mkdir /app
WORKDIR /app
COPY Gemfile* /app/
ARG BUNDLE_INSTALL_ARGS
RUN gem install bundler:2.3.25
RUN bundle config set without 'development test'
RUN bundle install ${BUNDLE_INSTALL_ARGS} \
&& rm -rf /usr/local/bundle/cache/* \
&& find /usr/local/bundle/gems/ -name "*.c" -delete \
&& find /usr/local/bundle/gems/ -name "*.o" -delete
COPY . /app/

# Compile assets
ARG RAILS_ENV=development
RUN if [ "$RAILS_ENV" = "production" ]; then SECRET_KEY_BASE=$(rake secret) bundle exec rake assets:precompile; fi
51 changes: 51 additions & 0 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM ruby:3.1.2

RUN apt-get update -yq \
&& apt-get upgrade -yq \
#ESSENTIALS
&& apt-get install -y -qq --no-install-recommends build-essential curl git-core vim passwd unzip cron gcc wget netcat \
# RAILS PACKAGES NEEDED
&& apt-get update \
&& apt-get install -y --no-install-recommends imagemagick postgresql-client \
# INSTALL NODE
&& curl -sL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
# INSTALL YARN
&& npm install -g yarn

# Clean cache and temp files, fix permissions
RUN apt-get clean -qy \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir /app
WORKDIR /app

COPY package.json yarn.lock
RUN yarn install

# install specific version of bundler
RUN gem install bundler -v 2.2.32

ENV BUNDLE_GEMFILE=/app/Gemfile \
BUNDLE_JOBS=20 \
BUNDLE_PATH=/bundle \
BUNDLE_BIN=/bundle/bin \
GEM_HOME=/bundle
ENV PATH="${BUNDLE_BIN}:${PATH}"

COPY Gemfile Gemfile.lock ./
RUN bundle install --binstubs --without development test

COPY . .

ENV RAILS_ENV production
ENV RAILS_SERVE_STATIC_FILES 1
ENV RAILS_LOG_TO_STDOUT 1

RUN SECRET_KEY_BASE=skb DB_ADAPTER=nulldb bundle exec rails assets:precompile

RUN chmod +x entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]

EXPOSE 3000
CMD bundle exec puma -C config/puma.rb
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ gem "bootsnap", require: false

group :development, :test do
# Use pg as the database for Active Record
gem "pg"
# gem "pg"
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri mingw x64_mingw ]
end
Expand All @@ -58,7 +58,7 @@ group :test do
end

group :production do
gem "pg"
# gem "pg"
gem "aws-sdk-s3", require: false
end

Expand All @@ -81,7 +81,7 @@ gem "redis"
# gem 'bootstrap-will_paginate'
# gem 'bootstrap-sass'
# gem 'sassc-rails'
# gem 'pg'
gem 'pg'
# gem 'mini_magick'
gem 'kaminari'
gem 'kaminari-bootstrap'
Expand Down
File renamed without changes.
26 changes: 7 additions & 19 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
All source code in the [Ruby on Rails Tutorial](https://www.railstutorial.org/) is available jointly under the MIT License and the Beerware License. (This means you can use one or the other or both.)
MIT License

```
The MIT License
Copyright (c) 2022 Michael Hartl
Copyright (c) 2022 Manh Nguyen

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 All @@ -12,22 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```

```
THE BEERWARE LICENSE (Revision 42)
Michael Hartl wrote this code. As long as you retain this notice you can do
whatever you want with this stuff. If we meet some day, and you think this
stuff is worth it, you can buy me a beer in return.
```
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit d213586

Please sign in to comment.