Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build and setup #83

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
- run: cp config/database.yml.docker config/database.yml
- run: cp docker-compose.yml.sample docker-compose.yml
- run: cp .env.sample .env
- run: docker compose build --build-arg RAILS_ENV=test
- run: docker compose pull
- run: docker compose build
- run: docker compose run -e RAILS_ENV=test --rm app bundle config set without 'development'
- run: docker compose run -e RAILS_ENV=test --rm app bundle install
- run: docker compose run -e RAILS_ENV=test --rm app yarn install
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ ENV BUNDLE_JOBS 8
ENV APP_HOME /myapp

ARG RAILS_ENV=production
ENV RAILS_ENV=$RAILS_ENV
ENV RACK_ENV=$RAILS_ENV
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arg is only available during build, but having those two envs here makes them permanent.

This can have an undesired effect in the test environment. In my testings, having those two lines make the test environment use the development database. Which is not a problem because everything runs inside a transaction but it is not ideal.

@parndt, please make sure you have both of them in fly ✌️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I take it back. I don't think my test environment was using development database because of these two lines.

Yet, I don't think it is a good idea to have the two envs because it makes them permanent.


COPY . $APP_HOME
WORKDIR $APP_HOME
Expand All @@ -24,7 +22,7 @@ RUN if [ "$RAILS_ENV" = "production" ]; then \
bundle config set --local without 'development test' \
&& bundle install \
&& yarn install \
&& bundle exec rake assets:precompile \
&& bundle exec rake assets:precompile ; \
fi

EXPOSE ${PORT:-3000}
Expand Down
43 changes: 38 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Keeps track of membership to a society.

## Getting started

(Docker version follows).

### Prerequisites

* Ruby (See `.ruby-version` for the version you have to install)
Expand All @@ -12,7 +14,13 @@ Keeps track of membership to a society.

### Set-up

Clone this repository and run the following from the working directory:
Install dependencies, copy `config/database.yml.sample` to `config/database.yml`:

cp config/database.yml.sample config/database.yml

Edit `config/database.yml` according to your setup.

Then run:

bin/setup
yarn install
Expand All @@ -31,14 +39,39 @@ And

yarn build --watch

## Testing

This codebase started out without tests. Some are being introduced over time.

To run tests:

bundle exec rspec

## Getting started (using docker)

Install [docker](https://docs.docker.com/engine/install/) and
[docker compose](https://docs.docker.com/compose/install/).

Copy files:

cp docker-compose.yml.sample docker-compose.yml
cp config/database.yml.docker config/database.yml

Edit them according to your setup and preferences.

NOTE: leave `RAILS_ENV: test` or change it to `RAILS_ENV: development` in
`docker-compose.yml`. Either value does the same.

Then run:

docker compose pull
docker compose build
docker compose run --rm app ./bin/setup

To start:

docker compose up app assets

To run the tests:

docker compose run --rm app bundle exec rspec

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate if anyone can review English and if it is easy to understand 🤗.

## Voting

Voting can be enabled by setting a `VOTE_URL_TEMPLATE` environment variable.
Expand Down
5 changes: 0 additions & 5 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ FileUtils.chdir APP_ROOT do
system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")

puts "\n== Copying sample files =="
unless File.exist?("config/database.yml")
FileUtils.cp "config/database.yml.sample", "config/database.yml"
end

puts "\n== Preparing database =="
system! "bin/rails db:prepare"

Expand Down
11 changes: 9 additions & 2 deletions docker-compose.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ services:
expose:
- "5432"

app:
build: .
assets: &ruby
build:
context: .
args:
RAILS_ENV: test
volumes:
- .:/app
- bundle_path:/usr/local/bundle
Expand All @@ -20,6 +23,10 @@ services:
- AUTH_NAME=secretary
- AUTH_PASSWORD=password
working_dir: /app
command: yarn build --watch

app:
<<: *ruby
command: bundle exec falcon serve -n 2 -b 'http://0.0.0.0:3000'
ports:
- "3000:3000"
Expand Down
Loading