Skip to content

Commit

Permalink
Merge branch 'supporter_level_goal' into update-react-dom
Browse files Browse the repository at this point in the history
  • Loading branch information
wwahammy authored Dec 21, 2024
2 parents 0087b13 + b4b4e70 commit 16e1a91
Show file tree
Hide file tree
Showing 174 changed files with 2,566 additions and 975 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.env
.env.test
Dockerfile
docker-compose.yml
README.md
.dockerignore
tmp
log
node_modules
.bin
vendor
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# put Eric as codeowner so he is autoadded to review every PR
* @wwahammy
11 changes: 6 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ on:
push:
branches: ["supporter_level_goal"]
concurrency:
group: build--${{ github.head_ref }}
group: build--${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
node: [14.19.1]
os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04]
node: [16]
ruby: ['2.6.10']
postgres: ['16']
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
Expand Down Expand Up @@ -54,7 +55,7 @@ jobs:
- name: Setup PostgreSQL with PostgreSQL extensions and unprivileged user
uses: Daniel-Marynicz/[email protected]
with:
postgres_image_tag: 12-alpine
postgres_image_tag: ${{ matrix.postgres }}-alpine
postgres_user: admin
postgres_password: password
- uses: actions/setup-node@v4
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04]
node: [14.19.1]
node: [16]
ruby: ['2.6.10']
postgres: ['16']
fail-fast: false
steps:
- name: 'Checkout our repo'
Expand All @@ -37,7 +38,7 @@ jobs:
- name: Setup PostgreSQL with PostgreSQL extensions and unprivileged user
uses: Daniel-Marynicz/[email protected]
with:
postgres_image_tag: 12-alpine
postgres_image_tag: ${{ matrix.postgres }}-alpine
postgres_user: admin
postgres_password: password
- uses: actions/setup-node@v4
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,9 @@ javascripts/api
/.yardoc

# Data files you wouldn't want to push
*.csv
*.csv

app/javascript/routes.js
app/javascript/routes.d.ts

vendor
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
14.19.1
16

2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ruby 2.6.10
nodejs 14.19.1
84 changes: 84 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# syntax=docker/dockerfile:1
ARG BASE_IMAGE=ruby
ARG RUBY_VERSION=2.6.10
ARG BASE_TAG=${RUBY_VERSION}-slim
ARG BASE=${BASE_IMAGE}:${BASE_TAG}

FROM ${BASE} AS builder

ENV LANG en_US.UTF-8

RUN apt-get update -qq \
&& apt-get install -y \
build-essential \
ca-certificates \
curl \
tzdata \
git \
nodejs \
yarn \
&& curl -sL https://deb.nodesource.com/setup_16.x | bash \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" \
> /etc/apt/sources.list.d/yarn.list \
&& apt-get update -qq \
&& apt-get install -y nodejs yarn \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ARG RAILS_ROOT=/app/

RUN mkdir ${RAILS_ROOT}
WORKDIR ${RAILS_ROOT}

COPY package.json yarn.lock ${RAILS_ROOT}
RUN yarn install

COPY . ${RAILS_ROOT}

# RUN bundle exec rake assets:precompile

FROM ${BASE}

ENV LANG en_US.UTF-8
RUN apt-get update -qq \
&& apt-get install -y libjemalloc2 tzdata libv8-dev curl default-jre git build-essential libpq-dev \
&& curl -sL https://deb.nodesource.com/setup_16.x | bash \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" \
> /etc/apt/sources.list.d/yarn.list \
&& apt-get update -qq \
&& apt-get install -y nodejs yarn \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ARG BASE_RELEASE=bullseye
RUN apt-get update -qq \
&& echo "deb https://apt.postgresql.org/pub/repos/apt ${BASE_RELEASE}-pgdg main" \
> /etc/apt/sources.list.d/pgdg.list \
&& curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg \
&& apt-get update -qq \
&& apt-get install -y postgresql-client-16 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN curl https://cli-assets.heroku.com/install.sh | sh

RUN groupadd --gid 1000 app && \
useradd --uid 1000 --no-log-init --create-home --gid app app

USER app

COPY --from=builder --chown=app:app /app /app

ENV RAILS_ENV=development
ENV IS_DOCKER=true
ENV RAILS_LOG_TO_STDOUT true
ENV RAILS_SERVE_STATIC_FILES true
ENV PORT 3000
ARG RAILS_ROOT=/app/

WORKDIR $RAILS_ROOT
RUN touch /home/app/.netrc
RUN mkdir -p tmp/pids
CMD bundle check || (bundle update --bundler && bundle install -j4 --retry 3) && foreman start
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ group :development, :ci do
end

group :development, :ci, :test do
gem 'letter_opener'
gem 'timecop'
gem 'pry'
gem 'pry-byebug'
Expand Down Expand Up @@ -184,4 +185,6 @@ gem 'fx', git: 'https://github.com/teoljungberg/fx.git', ref: '946cdccbd12333de

gem 'has_scope'

gem 'globalid', git: "https://github.com/CommitChange/globalid.git", tag: "0.4.2.1"
gem 'globalid', git: "https://github.com/CommitChange/globalid.git", tag: "0.4.2.1"

gem 'js-routes'
20 changes: 15 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ GEM
carrierwave-aws (1.4.0)
aws-sdk-s3 (~> 1.0)
carrierwave (>= 0.7, < 2.1)
childprocess (5.1.0)
logger (~> 1.5)
chronic (0.10.2)
coderay (1.1.3)
coercible (1.0.0)
Expand Down Expand Up @@ -280,6 +282,8 @@ GEM
jbuilder (2.9.1)
activesupport (>= 4.2.0)
jmespath (1.6.1)
js-routes (2.2.7)
railties (>= 4)
json (2.6.1)
kaminari (1.2.1)
activesupport (>= 4.1.0)
Expand All @@ -294,6 +298,12 @@ GEM
kaminari-core (= 1.2.1)
kaminari-core (1.2.1)
kdtree (0.3)
launchy (3.0.1)
addressable (~> 2.8)
childprocess (~> 5.0)
letter_opener (1.10.0)
launchy (>= 2.2, < 4)
logger (1.6.2)
lograge (0.3.6)
actionpack (>= 3)
activesupport (>= 3)
Expand Down Expand Up @@ -327,7 +337,7 @@ GEM
net-http-persistent (3.1.0)
connection_pool (~> 2.2)
netrc (0.11.0)
nio4r (2.5.9)
nio4r (2.7.0)
orm_adapter (0.5.0)
pg (0.21.0)
power_assert (1.1.1)
Expand All @@ -347,7 +357,7 @@ GEM
byebug (~> 11.0)
pry (~> 0.13.0)
public_suffix (4.0.6)
puma (5.6.7)
puma (5.6.9)
nio4r (~> 2.0)
puma_worker_killer (0.3.1)
get_process_mem (~> 0.2)
Expand Down Expand Up @@ -504,9 +514,7 @@ GEM
webmock (1.21.0)
addressable (>= 2.3.6)
crack (>= 0.3.2)
webrick (1.7.0)
yard (0.9.27)
webrick (~> 1.7.0)
yard (0.9.36)

PLATFORMS
ruby
Expand Down Expand Up @@ -556,8 +564,10 @@ DEPENDENCIES
httparty
i18n-js
jbuilder
js-routes
json (>= 2.3.0)
kaminari
letter_opener
lograge
mini_magick
nearest_time_zone
Expand Down
1 change: 0 additions & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
web: bundle exec puma -C ./config/puma.rb
worker: bundle exec rake jobs:work
full_contact_worker: bundle exec rake work_full_contact_queue
2 changes: 1 addition & 1 deletion Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
web: bin/rails server -p $PORT
web: /bin/bash -c '[[ $IS_DOCKER = "true" ]] && $(bundle exec puma -p $PORT -C ./config/puma.rb) || $(bin/rails server -p $PORT)'
worker: bin/rake jobs:work
webpack: yarn watch
68 changes: 59 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,43 @@ git clone https://github.com/Commitchange/houdini
git checkout supporter_level_goal
```

##### Get your .env file
If you don't already have access to the CommitChange 1Password vault, ask to be added. Then
download the .env file in 1Password and place it in the root directory.

> *Note:* Double check that your .env file has the '.' in front of the file name.
#### Dockerized
This is a work-in-progress method of running a development environment. The standard is still the bare metal instructions below.

Mac users can ignore this, but if your host machine is Linux, you might run into permission issues with the tmp files created by the postgres image. To proactively avoid this, run `cp docker-compose.override.yml.example docker-compose.override.yml` and change the values inside the newly copied file to match the output of `echo $(id -u):$(id -g)`

One-time setup:
```bash
touch ~/.netrc #prevents docker compose from creating it as a directory if you don't have it yet

docker-compose run web bin/rake db:setup
```

Running:
```bash
docker-compose up
```

Restoring the DB from Prod (Linux):
```bash
# Enter `password` when prompted for a password after the download step.
docker-compose exec web script/restore_from_heroku.sh
```

Restoring the DB from Prod (Mac). The above command will work on Mac, but will take an hour or more due to differences in how docker handles storage. Use the below to reduce how long it takes (will still take a long time).
```bash
curl -o ./tmp/shared/latest.dump `heroku pg:backups:url -a commitchange`

# Enter `password` when prompted for a password.
docker-compose exec db -e CC_PROD_DUMP_PATH="/tmp/shared/latest.dump" script/pg_restore_local_from_production.sh
```

#### One-time setup (Ubuntu)

You'll want to run the next commands as root or via sudo (for Ubuntu 18.04 users or anyone running ProgresSQL 10, change "postgresql-12" below to "postgresql-10"). You could do this by typing `sudo /bin/sh` running the commands from there.
Expand Down Expand Up @@ -117,17 +154,33 @@ echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This
# Reference Stack Overflow post: https://stackoverflow.com/questions/53118850/brew-install-nvm-nvm-command-not-found
```

Make sure you've installed Yarn.

```bash
yarn --version
brew install yarn
```

Set your Postgres version with homebrew.

```bash
brew install postgresql@12
brew switch postgres@12
brew install postgresql@16
brew switch postgres@16

# To start postgres locally run:
brew services start postgresql@12
brew services start postgresql@16

```

You might get segmentation faults if you don't configure `pg` with the correct macports. One of these should work.
```bash
gem install pg -- --with-pg-config="${HOMEBREW_PREFIX}/opt/libpq/bin/pg_config"
# Or?
bundle config build.pg --with-pg-config="${HOMEBREW_PREFIX}/opt/libpq/bin/pg_config"
```

You may also need to set the env variable `PGGSSENCMODE=disable` to resolve segmentation faults.

Create necessary postgres users in the `psql` console.

```bash
Expand All @@ -136,19 +189,16 @@ CREATE ROLE admin WITH SUPERUSER CREATEDB LOGIN PASSWORD 'password';
CREATE ROLE postgres WITH SUPERUSER CREATEDB LOGIN PASSWORD 'password';
```

You may need to disable AirPlay Receiver in your System Settings if it is hogging port 5000.


#### System configuration (all)
There are a number of steps for configuring your Houdini instance for startup
##### Run bin/setup
```sh
bin/setup
```

##### Get your .env file
If you don't already have access to the CommitChange 1Password vault, ask to be added. Then
download the .env file in 1Password and place it in the root directory.

> *Note:* Double check that your .env file has the '.' in front of the file name.
#### Startup
##### run foreman for development

Expand Down
1 change: 0 additions & 1 deletion app/assets/stylesheets/common/donate_button.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later */
@import 'mixins';
@import 'nonprofits/donation_form/title_row';
@import 'nonprofits/donation_form/footer';
@import 'nonprofits/donation_form/form'; // for styling the actual form
@import 'nonprofits/donation_form/show/index'; // for styling the layout on /donate
Loading

0 comments on commit 16e1a91

Please sign in to comment.