Skip to content

Commit 36dc633

Browse files
authored
Merge pull request #52 from calebl/rails-8-upgrade
upgrade to rails 8; all tests pass
2 parents 4220987 + cbf8d70 commit 36dc633

39 files changed

Lines changed: 1257 additions & 635 deletions

.devcontainer/Dockerfile

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# syntax=docker/dockerfile:1
2+
# check=error=true
3+
4+
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
5+
ARG RUBY_VERSION=3.3.8
6+
FROM ruby:$RUBY_VERSION-slim AS base
7+
8+
# Rails app lives here
9+
WORKDIR /rails
10+
11+
# Update gems and bundler
12+
RUN gem update --system --no-document && \
13+
gem install -N bundler
14+
15+
# Install base packages
16+
RUN apt-get update -qq && \
17+
apt-get install --no-install-recommends -y \
18+
curl \
19+
git \
20+
openssh-client \
21+
libjemalloc2 \
22+
sqlite3 \
23+
libsqlite3-dev && \
24+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
25+
26+
# Set production environment
27+
ENV BUNDLE_DEPLOYMENT="1" \
28+
BUNDLE_PATH="/usr/local/bundle" \
29+
BUNDLE_WITHOUT="production" \
30+
RAILS_ENV="development"
31+
32+
33+
# Throw-away build stage to reduce size of final image
34+
FROM base AS build
35+
36+
# Install packages needed to build gems
37+
RUN apt-get update -qq && \
38+
apt-get install --no-install-recommends -y build-essential libffi-dev libyaml-dev libsqlite3-dev && \
39+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
40+
41+
# Install application gems
42+
COPY Gemfile Gemfile.lock ./
43+
RUN bundle install && \
44+
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
45+
bundle exec bootsnap precompile --gemfile
46+
47+
# Copy application code
48+
COPY . .
49+
50+
# Precompile bootsnap code for faster boot times
51+
RUN bundle exec bootsnap precompile app/ lib/
52+
53+
# Precompiling assets
54+
RUN ./bin/rails assets:precompile
55+
56+
57+
# Final stage for app image
58+
FROM base AS development
59+
60+
# Copy built artifacts: gems, application
61+
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
62+
COPY --from=build /rails /rails
63+
64+
# Run and own only the runtime files as a non-root user for security
65+
RUN groupadd --system --gid 1000 rails && \
66+
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
67+
chown -R 1000:1000 db log storage tmp
68+
USER 1000:1000
69+
70+
# Entrypoint prepares the database.
71+
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
72+
73+
# Start the server by default, this can be overwritten at runtime
74+
EXPOSE 8080
75+
CMD ["./bin/rails", "server", "-p", "8080"]

.devcontainer/devcontainer.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "Draft Dev Container",
3+
"build": {
4+
"dockerfile": "./Dockerfile",
5+
"context": ".."
6+
},
7+
"forwardPorts": [8080],
8+
"postCreateCommand": "bin/setup --skip-server && mkdir -p ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts",
9+
"settings": {
10+
"git.path": "/opt/homebrew/bin/git",
11+
"terminal.integrated.shell.linux": "/bin/zsh",
12+
"terminal.integrated.defaultProfile.linux": "zsh",
13+
"ghcr.io/devcontainers/features/github-cli:1": {},
14+
"ghcr.io/devcontainers/features/git:1": {}
15+
},
16+
"extensions": [
17+
"rebornix.Ruby",
18+
"castwide.solargraph"
19+
],
20+
"runArgs": ["--name", "draft-dev-container"]
21+
}

.dockerignore

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
2+
3+
# Ignore git directory.
4+
/.git/
5+
/.gitignore
6+
7+
# Ignore bundler config.
8+
/.bundle
9+
10+
# Ignore all environment files.
11+
/.env*
12+
13+
# Ignore all default key files.
14+
/config/master.key
15+
/config/credentials/*.key
16+
17+
# Ignore all logfiles and tempfiles.
18+
/log/*
19+
/tmp/*
20+
!/log/.keep
21+
!/tmp/.keep
22+
23+
# Ignore pidfiles, but keep the directory.
24+
/tmp/pids/*
25+
!/tmp/pids/.keep
26+
27+
# Ignore storage (uploaded files in development and any SQLite databases).
28+
/storage/*
29+
!/storage/.keep
30+
/tmp/storage/*
31+
!/tmp/storage/.keep
32+
33+
# Ignore assets.
34+
/node_modules/
35+
/app/assets/builds/*
36+
!/app/assets/builds/.keep
37+
/public/assets
38+
39+
# Ignore CI service files.
40+
/.github
41+
42+
# Ignore Kamal files.
43+
/config/deploy*.yml
44+
/.kamal
45+
46+
# Ignore development files
47+
/.devcontainer
48+
49+
# Ignore Docker-related files
50+
/.dockerignore
51+
/Dockerfile*

.rubocop.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
inherit_from: .rubocop_todo.yml
2+
3+
plugins:
4+
- rubocop-rails
5+
6+
inherit_mode:
7+
merge:
8+
- Exclude
9+
10+
AllCops:
11+
NewCops: enable
12+
TargetRubyVersion: 3.3
13+
TargetRailsVersion: 8.0
14+
SuggestExtensions: false
15+
16+
Style/Documentation:
17+
Enabled: false

0 commit comments

Comments
 (0)