Skip to content
Closed
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
13 changes: 7 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
APP_HOST='localhost'
APP_PORT='80' # If you change the port, you must reflect it in the docker-compose file!
DEAD_PID_URL='http://localhost:80/link/inactive' # If you change the port you must update this URL.
SESSION_SECRET='your_session_secret_here'
# Must be at least 64 characters. Generate a real local value with: openssl rand -hex 32
SESSION_SECRET='0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'
ACCOUNT_LOCK_EMAIL_TO='your_email_here'

# Redis
Expand All @@ -14,14 +15,14 @@ REDIS_PORT='6379' # Default port for redis. If you change the port, you must ref
REDIS_USE_SSL='false'

# Database Credentials (Secrets)
DB_HOST='host.docker.internal' # References the host machine for the docker container
DB_NAME='your_db_name_here'
DB_USERNAME='your_db_username_here'
DB_PASSWORD='your_db_password_here'
DB_HOST='mysql' # References the mysql container in docker-compose.yml
DB_NAME='pid_dev'
DB_USERNAME='pid'
DB_PASSWORD='devpassword'

# SMTP Credentials (Secrets)
SMTP_HOST='your_smtp_host_here'
SMTP_PORT='587' # Default port for SMTP
SMTP_USERNAME='your_smtp_username_here'
SMTP_PASSWORD='your_smtp_password_here'
SMTP_SENDER_ADDRESS='your_email_here'
SMTP_SENDER_ADDRESS='your_email_here'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*.rdb
*.log
.DS_Store
.data/
vendor
app/config/*.yml
log/*_log
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ When the third party moves that article to some.site.org/new/path/to/same/file.h

The whole application, including dependencies like Redis, is Dockerized and can be run as a container. Libraries and packages are managed by Bundler; please refer to the Gemfile and Gemfile.lock files for more information. Aside from those, here is a list of things you need to run the application on your machine:
- [Docker](https://www.docker.com/products/docker-desktop/)
- A MySQL database to act as a database for the service (see the Database Structure section).
- A MySQL database to act as a database for the service (see the Database Structure section). The Docker Compose setup includes a local MySQL container for development.
- SMTP server for sending emails. This only concerns the password reset feature.

## Installation
To run the application locally, do the following:
- Install Docker
- Make sure you have a MySQL database ready for this system to use.
- Make sure you have a MySQL database ready for this system to use, or use the MySQL container included in the Docker Compose setup.
- Optionally get an SMTP server for sending emails.
- Clone the repository: `git clone https://github.com/cdlib/pid`
- Refer to the [README](https://github.com/cdlib/pid/blob/master/app/README.md) file in the app directory for more information on running the application.

To deploy the application in the cloud, refer to the [pid-env](https://github.com/cdlib/pid-env/tree/master) repository.
To deploy the application in the cloud, refer to the [pid-env](https://github.com/cdlib/pid-env/tree/master) repository.
5 changes: 2 additions & 3 deletions app/Dockerfile.app
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
ARG TARGET_PLATFORM=linux/amd64
ARG IMAGE_TAG=3.3.7-slim-bullseye

FROM --platform=${TARGET_PLATFORM} ruby:${IMAGE_TAG} AS base
FROM ruby:${IMAGE_TAG} AS base

RUN apt-get update -qq \
&& apt-get install -y \
Expand All @@ -26,7 +25,7 @@ COPY Gemfile Gemfile.lock ./
RUN bundle config set --local without 'test' && \
bundle install

FROM --platform=$TARGET_PLATFORM base AS final
FROM base AS final

COPY --from=dependencies /usr/local/bundle /usr/local/bundle

Expand Down
5 changes: 3 additions & 2 deletions app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
> Generate a 64-character hex for the session secret. The SMTP stuff is optional.
- Replace `/app/config/*.yml.example` files with `*.yml` versions.
> The `.example` files are primarily for reference, though they will be sufficient to get the app running; you can modify the values to implement your own configuration. Naturally, if you wish to connect to an external database, you may need to be on VPN.
> The default `.env.example` database values use the local MySQL container defined in `docker-compose.yml`.

## Docker Installation
### Running the Appplication
- Using `docker-compose`:
- Run `docker-compose up --build` to build and start the application.
> This will build the Redis container as well as the application container, but only after making sure the tests pass. You can modify the `docker-compose.yml` file to skip the tests.
> This will build MySQL, Redis, the schema bootstrap container, and the application container, but only after making sure the tests pass. You can modify the `docker-compose.yml` file to skip the tests.
- As you update the application, rebuild by running `docker-compose build`.
- To start the application without or after rebuilding, run `docker-compose up`.
- To tear down, run `docker-compose down`.
Expand Down Expand Up @@ -151,4 +152,4 @@ MySQL Table Overview
- **Invalid_url_reports** - A table that stores a list of invalid URLs (i.e. Pinging the URL returns an HTTP >= 400 status code). This table is populated by a job that is kicked off by Cron each weekend.
- **Skip_checks** - A table that stores the domains of URLs were a contractually not allowed to run the invalid URLs check against

Please refer to the schema file `/app/db/schema.rb` to see the structure of the database. The schema file was generated by Active Record while connected to the actual database for the service. It is currently used to initialize the database for testing with SQLite, so it should be a good reference, though unfortunately it doesn't include the indexes and constraints. Please contact one of the developers for more information.
Please refer to the schema file `/app/db/schema.rb` to see the structure of the database. The schema file was generated by Active Record while connected to the actual database for the service. It is currently used to initialize the database for testing with SQLite, so it should be a good reference, though unfortunately it doesn't include the indexes and constraints. Please contact one of the developers for more information.
30 changes: 30 additions & 0 deletions deployment/app_config/app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Used for the title and header on layout.erb
organization_name: 'California Digital Library'
application_name: 'PID Service'

# The server and port where the main PID application will be hosted (comment out the port if you do not need to specify)
app_host: <%= ENV['APP_HOST'] %>
app_port: <%= ENV['APP_PORT'] %>

# The url that the system should direct users to when an inactive PID is requested
dead_pid_url: <%= ENV['DEAD_PID_URL'] %>

# Redis host and port are required
redis_host: <%= ENV['REDIS_HOST'] %>
redis_port: <%= ENV['REDIS_PORT'] %>
redis_use_ssl: <%= ENV['REDIS_USE_SSL'] %>

# Limit the number of results that are returned during a PID search
search_results_limit: 50

# The maximum CSV file size allowed for upload on the Edit PID page (in kb)
max_upload_csv_size: 10240 #10MB

# The email address that the system uses to send mail (SMTP)
email_sender_address: <%= ENV['SMTP_SENDER_ADDRESS'] %>

# Smtp settings if we're using that
smtp_host: <%= ENV['SMTP_HOST'] %>
smtp_port: <%= ENV['SMTP_PORT'] %>
smtp_username: <%= ENV['SMTP_USERNAME'] %>
smtp_password: <%= ENV['SMTP_PASSWORD'] %>
8 changes: 8 additions & 0 deletions deployment/app_config/db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# DB connection settings
db_adapter: 'mysql2'
db_encoding: 'utf8'
db_host: <%= ENV['DB_HOST'] %>
db_port: 3306
db_name: <%= ENV['DB_NAME'] %>
db_username: <%= ENV['DB_USERNAME'] %>
db_password: <%= ENV['DB_PASSWORD'] %>
Loading