Skip to content

Commit 6961329

Browse files
committed
Merge branch 'develop'
2 parents 8f158e6 + 71c1353 commit 6961329

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+806
-871
lines changed

.circleci/config.yml

Lines changed: 0 additions & 77 deletions
This file was deleted.

.dockerignore

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,39 @@
1-
.git
1+
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
2+
3+
# Ignore git directory.
4+
/.git/
5+
6+
# Ignore bundler config.
7+
/.bundle
8+
9+
# Ignore all default key files.
10+
/config/master.key
11+
/config/credentials/*.key
12+
13+
# Ignore all environment files.
14+
/.env*
15+
!/.env.example
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/
26+
!/tmp/pids/.keep
27+
28+
# Ignore storage (uploaded files in development and any SQLite databases).
29+
/storage/*
30+
!/storage/.keep
31+
/tmp/storage/*
32+
!/tmp/storage/
33+
!/tmp/storage/.keep
34+
35+
# Ignore assets.
36+
/node_modules/
37+
/app/assets/builds/*
38+
!/app/assets/builds/.keep
39+
/public/assets

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: bundler
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
time: "10:00"
8+
open-pull-requests-limit: 10

.github/workflows/ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: CI
2+
3+
on: [push]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
9+
env:
10+
PGHOST: 127.0.0.1
11+
PGUSER: klaxon-test-user
12+
PGPASSWORD: "LjRKZViA88dMumv"
13+
RAILS_ENV: test
14+
RACK_ENV: test
15+
NODE_ENV: test
16+
17+
services:
18+
postgres:
19+
image: postgres:9.5
20+
env:
21+
POSTGRES_DB: klaxon_test
22+
POSTGRES_USER: klaxon-test-user
23+
POSTGRES_PASSWORD: "LjRKZViA88dMumv"
24+
ports:
25+
- 5432:5432
26+
27+
steps:
28+
- name: Checkout the project
29+
uses: actions/checkout@v3
30+
31+
- name: Set up Ruby
32+
uses: ruby/setup-ruby@v1
33+
with:
34+
bundler-cache: true
35+
36+
- name: Compile assets
37+
run: bundle exec rake assets:precompile assets:clean
38+
39+
- name: Prepare the database
40+
run: bundle exec rake db:create db:schema:load --trace
41+
42+
- name: Run the tests
43+
run: bundle exec rspec --tag ~skip --tag ~pending --format RSpec::Github::Formatter

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ backups/
1010
pull_dev_database.sh
1111

1212
snapshots
13+
14+
/app/assets/builds/*
15+
!/app/assets/builds/.keep

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18.16.0

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.7.2
1+
3.1.4

DEVELOPING.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Developing Klaxon Locally #
1+
# Developing Klaxon Locally
22

33
If you're interested in [helping improve Klaxon by contributing code](CONTRIBUTING.md), this is a quick guide to how to get it running on your local machine for development.
44

@@ -8,24 +8,23 @@ First, we'll assume you already have git on your local machine, as well as a sta
88
git clone [email protected]:themarshallproject/klaxon.git
99
```
1010

11-
After you've cloned it, `cd` into the Klaxon directory. If you're on a Mac, you'll need to already have [homebrew](https://brew.sh/) and [rbenv](https://github.com/rbenv/rbenv) (a program that manages versions of Ruby) installed. Then you'll want
11+
After you've cloned it, `cd` into the Klaxon directory. If you're on a Mac, you'll need to already have [homebrew](https://brew.sh/) and [rbenv](https://github.com/rbenv/rbenv) (a program that manages versions of Ruby) installed. Then you'll want
1212

1313
These next commands will put the proper (albeit aged) version of Ruby that Klaxon requires on your machine and make it available in this repo's directory.
1414

1515
```
1616
brew update && brew upgrade ruby-build
1717
rbenv install
18-
```
18+
```
1919

20-
Next, you'll need to have the proper versions of all of Klaxon's dependency libraries, as well as foreman, a process manager that allows you to run a local server for development. Run these commands here.
20+
Next, you'll need to have the proper versions of all of Klaxon's dependency libraries. Run these commands here.
2121

2222
```
2323
gem install bundler
2424
bundle install
25-
gem install foreman
2625
```
2726

28-
In order to be allowed to login to Klaxon once it's running on your machine, it'll need to know that your email address is. Create a file named `.env` and paste in these two items:
27+
In order to be allowed to login to Klaxon once it's running on your machine, it'll need to know that your email address is. Create a file named `.env` and paste in these two items:
2928

3029
```
3130
ADMIN_EMAILS="[email protected]"
@@ -37,17 +36,17 @@ Feel free to substitute in your email address. In development, Klaxon doesn't ac
3736
Now that's set, you'll run a couple of commands for Rails to create Klaxon's database on your machine.
3837

3938
```
40-
rake db:create
41-
rake db:migrate
39+
bin/rake db:create
40+
bin/rake db:migrate
4241
```
4342

4443
Now, you should be about ready to get started. This command in the top folder of the Klaxon repo will get your dev server rolling.
4544

4645
```
47-
foreman start
46+
bin/dev
4847
```
4948

50-
Now, you should be able to go to [localhost:5000](http://localhost:5000/) in your web browser and see Klaxon's welcome screen pop up. You'll want to manually add a webpage or two to watch at [watching/pages/new](http://localhost:5000/watching/pages/new). For development purposes, you'll probably want to pick a site that updates pretty regularly. We use [http://www.timeanddate.com/](http://www.timeanddate.com/).
49+
Now, you should be able to go to [localhost:5000](http://localhost:5000/) in your web browser and see Klaxon's welcome screen pop up. You'll want to manually add a webpage or two to watch at [watching/pages/new](http://localhost:5000/watching/pages/new). For development purposes, you'll probably want to pick a site that updates pretty regularly. We use [http://www.timeanddate.com/](http://www.timeanddate.com/).
5150

5251
To get Klaxon to check for updates on the pages you're watching, in another terminal window, run this rake command.
5352

DOCKER.md

Lines changed: 0 additions & 42 deletions
This file was deleted.

Dockerfile

Lines changed: 76 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,84 @@
1-
FROM ruby:2.7.2
1+
# syntax = docker/dockerfile:1
22

3-
# throw errors if Gemfile has been modified since Gemfile.lock
4-
RUN bundle config --global frozen 1
3+
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
4+
ARG RUBY_VERSION=3.1.4
5+
FROM ruby:$RUBY_VERSION-slim as base
56

6-
RUN mkdir -p /usr/src/app
7-
WORKDIR /usr/src/app
7+
# Rails app lives here
8+
WORKDIR /rails
89

9-
COPY Gemfile /usr/src/app/
10-
COPY Gemfile.lock /usr/src/app/
11-
RUN bundle install
10+
# Set production environment
11+
ENV RAILS_ENV="production" \
12+
BUNDLE_WITHOUT="development:test" \
13+
BUNDLE_DEPLOYMENT="1"
1214

13-
COPY . /usr/src/app
15+
# Update gems and bundler
16+
RUN gem update --system --no-document && \
17+
gem install -N bundler
1418

15-
EXPOSE 3000
19+
# Install packages needed to install nodejs
20+
RUN apt-get update -qq && \
21+
apt-get install --no-install-recommends -y curl && \
22+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
23+
24+
# Install Node.js
25+
ARG NODE_VERSION=18.16.0
26+
ENV PATH=/usr/local/node/bin:$PATH
27+
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
28+
/tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
29+
rm -rf /tmp/node-build-master
30+
31+
32+
# Throw-away build stage to reduce size of final image
33+
FROM base as build
34+
35+
# Install packages needed to build gems
36+
RUN apt-get update -qq && \
37+
apt-get install --no-install-recommends -y build-essential libpq-dev
38+
39+
# Build options
40+
ENV PATH="/usr/local/node/bin:$PATH"
41+
42+
# Install application gems
43+
COPY --link Gemfile Gemfile.lock ./
44+
RUN bundle install && \
45+
bundle exec bootsnap precompile --gemfile && \
46+
rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git
47+
48+
# Copy application code
49+
COPY --link . .
1650

17-
# install s6overlay so that we can run cron inside this container as well.
18-
ADD https://github.com/just-containers/s6-overlay/releases/download/v1.21.8.0/s6-overlay-amd64.tar.gz /tmp/
19-
RUN tar xzf /tmp/s6-overlay-amd64.tar.gz -C / \
20-
&& mkdir /config \
21-
&& apt-get update \
22-
&& apt-get install -y cron \
23-
&& rm -rf /var/lib/apt/lists/*
51+
# Precompile bootsnap code for faster boot times
52+
RUN bundle exec bootsnap precompile app/ lib/
2453

25-
COPY rootfs/ /
26-
VOLUME ["/config"]
54+
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
55+
RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile
2756

28-
ENTRYPOINT ["/init"]
57+
58+
# Final stage for app image
59+
FROM base
60+
61+
# Install packages needed for deployment
62+
RUN apt-get update -qq && \
63+
apt-get install --no-install-recommends -y curl postgresql-client && \
64+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
65+
66+
# Copy built artifacts: gems, application
67+
COPY --from=build /usr/local/bundle /usr/local/bundle
68+
COPY --from=build /rails /rails
69+
70+
# Run and own only the runtime files as a non-root user for security
71+
RUN useradd rails --create-home --shell /bin/bash && \
72+
chown -R rails:rails db log tmp
73+
USER rails:rails
74+
75+
# Deployment options
76+
ENV RAILS_LOG_TO_STDOUT="1" \
77+
RAILS_SERVE_STATIC_FILES="true"
78+
79+
# Entrypoint prepares the database.
80+
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
81+
82+
# Start the server by default, this can be overwritten at runtime
83+
EXPOSE 3000
84+
CMD ["./bin/rails", "server"]

0 commit comments

Comments
 (0)