Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmurphy committed Jul 5, 2023
2 parents 8f158e6 + 71c1353 commit 6961329
Show file tree
Hide file tree
Showing 87 changed files with 806 additions and 871 deletions.
77 changes: 0 additions & 77 deletions .circleci/config.yml

This file was deleted.

40 changes: 39 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
.git
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.

# Ignore git directory.
/.git/

# Ignore bundler config.
/.bundle

# Ignore all default key files.
/config/master.key
/config/credentials/*.key

# Ignore all environment files.
/.env*
!/.env.example

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/
!/tmp/pids/.keep

# Ignore storage (uploaded files in development and any SQLite databases).
/storage/*
!/storage/.keep
/tmp/storage/*
!/tmp/storage/
!/tmp/storage/.keep

# Ignore assets.
/node_modules/
/app/assets/builds/*
!/app/assets/builds/.keep
/public/assets
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: bundler
directory: "/"
schedule:
interval: daily
time: "10:00"
open-pull-requests-limit: 10
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI

on: [push]

jobs:
test:
runs-on: ubuntu-latest

env:
PGHOST: 127.0.0.1
PGUSER: klaxon-test-user
PGPASSWORD: "LjRKZViA88dMumv"
RAILS_ENV: test
RACK_ENV: test
NODE_ENV: test

services:
postgres:
image: postgres:9.5
env:
POSTGRES_DB: klaxon_test
POSTGRES_USER: klaxon-test-user
POSTGRES_PASSWORD: "LjRKZViA88dMumv"
ports:
- 5432:5432

steps:
- name: Checkout the project
uses: actions/checkout@v3

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: Compile assets
run: bundle exec rake assets:precompile assets:clean

- name: Prepare the database
run: bundle exec rake db:create db:schema:load --trace

- name: Run the tests
run: bundle exec rspec --tag ~skip --tag ~pending --format RSpec::Github::Formatter
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ backups/
pull_dev_database.sh

snapshots

/app/assets/builds/*
!/app/assets/builds/.keep
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.16.0
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.2
3.1.4
19 changes: 9 additions & 10 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Developing Klaxon Locally #
# Developing Klaxon Locally

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.

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

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
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

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.

```
brew update && brew upgrade ruby-build
rbenv install
```
```

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.
Next, you'll need to have the proper versions of all of Klaxon's dependency libraries. Run these commands here.

```
gem install bundler
bundle install
gem install foreman
```

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:
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:

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

```
rake db:create
rake db:migrate
bin/rake db:create
bin/rake db:migrate
```

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.

```
foreman start
bin/dev
```

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/).
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/).

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

Expand Down
42 changes: 0 additions & 42 deletions DOCKER.md

This file was deleted.

96 changes: 76 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,84 @@
FROM ruby:2.7.2
# syntax = docker/dockerfile:1

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

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Rails app lives here
WORKDIR /rails

COPY Gemfile /usr/src/app/
COPY Gemfile.lock /usr/src/app/
RUN bundle install
# Set production environment
ENV RAILS_ENV="production" \
BUNDLE_WITHOUT="development:test" \
BUNDLE_DEPLOYMENT="1"

COPY . /usr/src/app
# Update gems and bundler
RUN gem update --system --no-document && \
gem install -N bundler

EXPOSE 3000
# Install packages needed to install nodejs
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Install Node.js
ARG NODE_VERSION=18.16.0
ENV PATH=/usr/local/node/bin:$PATH
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
/tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
rm -rf /tmp/node-build-master


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build gems
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential libpq-dev

# Build options
ENV PATH="/usr/local/node/bin:$PATH"

# Install application gems
COPY --link Gemfile Gemfile.lock ./
RUN bundle install && \
bundle exec bootsnap precompile --gemfile && \
rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git

# Copy application code
COPY --link . .

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

COPY rootfs/ /
VOLUME ["/config"]
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile

ENTRYPOINT ["/init"]

# Final stage for app image
FROM base

# Install packages needed for deployment
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl postgresql-client && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Copy built artifacts: gems, application
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build /rails /rails

# Run and own only the runtime files as a non-root user for security
RUN useradd rails --create-home --shell /bin/bash && \
chown -R rails:rails db log tmp
USER rails:rails

# Deployment options
ENV RAILS_LOG_TO_STDOUT="1" \
RAILS_SERVE_STATIC_FILES="true"

# Entrypoint prepares the database.
ENTRYPOINT ["/rails/bin/docker-entrypoint"]

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD ["./bin/rails", "server"]
Loading

0 comments on commit 6961329

Please sign in to comment.