Skip to content

Commit

Permalink
Merge pull request #2803 from postalserver/v3
Browse files Browse the repository at this point in the history
Postal v3
  • Loading branch information
adamcooke committed Mar 4, 2024
2 parents 66d26c8 + e4638a0 commit 2359829
Show file tree
Hide file tree
Showing 241 changed files with 11,754 additions and 4,702 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
name: CI Image Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: docker/setup-buildx-action@v2
Expand All @@ -37,13 +37,14 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
target: ci
platforms: linux/amd64

test:
name: Test Suite
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: docker/login-action@v2
Expand All @@ -64,7 +65,8 @@ jobs:
needs: [build]
if: startsWith(github.ref, 'refs/heads/')
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
Expand All @@ -86,14 +88,16 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
target: full
platforms: linux/amd64

publish-image:
name: Publish Image
runs-on: ubuntu-latest
needs: [build, test, release-please]
if: ${{ needs.release-please.outputs.release_created }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
Expand All @@ -111,3 +115,4 @@ jobs:
target: full
build-args: |
VERSION=${{ needs.release-please.outputs.version }}
platforms: linux/amd64,linux/arm64/v8
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ Procfile.local
VERSION

.rubocop-https*
.env*

1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ AllCops:
- "db/schema.rb"
# Fixes missing gem exception when running Rubocop on GitHub Actions.
- "vendor/bundle/**/*"
- lib/tasks/auto_annotate_models.rake

# Always use double quotes
Style/StringLiterals:
Expand Down
3 changes: 1 addition & 2 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
3.2.1

3.2.2
53 changes: 53 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Contributing to Postal

This doc explains how to go about running Postal in development to allow you to make contributions to the project.

## Dependencies

You will need a MySQL database server to get started. Postal needs to be able to make databases within that server whenever new mail servers are created so the permissions that you use should be suitable for that.

You'll also need Ruby. Postal currently uses Ruby 3.2.2. Install that using whichever version manager takes your fancy - rbenv, asdf, rvm etc.

## Clone

You'll need to clone the repository

```
git clone git@github.com:postalserver/postal
```

Once cloned, you can install the Ruby dependencies using bundler.

```
bundle install
```

## Configuration

Configuration is handled using a config file. This lives in `config/postal/postal.yml`. An example configuration file is provided in `config/examples/development.yml`. This example is for development use only and not an example for production use.

You'll also need a key for signing. You can generate one of these like this:

```
openssl genrsa -out config/postal/signing.key 2048
```

If you're running the tests (and you probably should be), you'll find an example file for test configuration in `config/examples/test.yml`. This should be placed in `config/postal/postal.test.yml` with the appropriate values.

If you prefer, you can configure Postal using environment variables. These should be placed in `.env` or `.env.test` as apprpriate.

## Running

The neatest way to run postal is to ensure that `./bin` is your `$PATH` and then use one of the following commands.

* `bin/dev` - will run all components of the application using Foreman
* `bin/postal` - will run the Postal binary providing access to running individual components or other tools.

## Database initialization

Use the commands below to initialize your database and make your first user.

```
postal initialize
postal make-user
```
19 changes: 11 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM ruby:3.2.1-bullseye AS base
FROM ruby:3.2.2-bullseye AS base

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
software-properties-common dirmngr apt-transport-https \
&& (curl -sL https://deb.nodesource.com/setup_14.x | bash -) \
&& (curl -sL https://deb.nodesource.com/setup_20.x | bash -) \
&& rm -rf /var/lib/apt/lists/*

# Install main dependencies
Expand All @@ -31,12 +31,12 @@ RUN mkdir -p /opt/postal/app /opt/postal/config
WORKDIR /opt/postal/app

# Install bundler
RUN gem install bundler -v 2.4.9 --no-doc
RUN gem install bundler -v 2.5.6 --no-doc

# Install the latest and active gem dependencies and re-run
# the appropriate commands to handle installs.
COPY Gemfile Gemfile.lock ./
RUN bundle config set force_ruby_platform true && bundle install -j 4
COPY --chown=postal Gemfile Gemfile.lock ./
RUN bundle install

# Copy the application (and set permissions)
COPY ./docker/wait-for.sh /docker-entrypoint.sh
Expand All @@ -46,8 +46,11 @@ COPY --chown=postal . .
ARG VERSION=unspecified
RUN echo $VERSION > VERSION

# Set the path to the config
ENV POSTAL_CONFIG_ROOT=/config
# Set paths for when running in a container
ENV POSTAL_CONFIG_FILE_PATH=/config/postal.yml
ENV POSTAL_SIGNING_KEY_PATH=/config/signing.key
ENV SMTP_SERVER_TLS_CERTIFICATE_PATH=/config/smtp.cert
ENV SMTP_SERVER_TLS_PRIVATE_KEY_PATH=/config/smtp.key

# Set the CMD
ENTRYPOINT [ "/docker-entrypoint.sh" ]
Expand All @@ -59,5 +62,5 @@ FROM base AS ci
# full target - default if no --target option is given
FROM base AS full

RUN POSTAL_SKIP_CONFIG_CHECK=1 RAILS_GROUPS=assets bundle exec rake assets:precompile
RUN RAILS_GROUPS=assets bundle exec rake assets:precompile
RUN touch /opt/postal/app/public/assets/.prebuilt
24 changes: 10 additions & 14 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,34 @@
source "https://rubygems.org"
gem "authie"
gem "autoprefixer-rails"
gem "basic_ssl"
gem "bcrypt"
gem "bunny"
gem "changey"
gem "chronic"
gem "clockwork"
gem "dotenv-rails"
gem "domain_name"
gem "dotenv"
gem "dynamic_form"
gem "encrypto_signo"
gem "execjs", "~> 2.7", "< 2.8"
gem "foreman"
gem "gelf"
gem "haml"
gem "hashie"
gem "highline", require: false
gem "jwt"
gem "kaminari"
gem "klogger-logger"
gem "konfig-config", "~> 2.0"
gem "mail"
gem "moonrope"
gem "mysql2"
gem "nifty-utils"
gem "nilify_blanks"
gem "nio4r"
gem "prometheus-client"
gem "puma"
gem "rails", "= 6.1.7.6"
gem "resolv", "~> 0.2.1"
gem "rails", "= 7.0.8.1"
gem "resolv"
gem "secure_headers"
gem "sentry-rails"
gem "sentry-ruby"
gem "turbolinks", "~> 5"
gem "webrick"

group :development, :assets do
gem "coffee-rails", "~> 5.0"
Expand All @@ -41,10 +39,6 @@ group :development, :assets do
gem "uglifier", ">= 1.3.0"
end

group :development, :test do
gem "byebug"
end

group :development do
gem "annotate"
gem "database_cleaner", require: false
Expand All @@ -53,5 +47,7 @@ group :development do
gem "rspec-rails", require: false
gem "rubocop"
gem "rubocop-rails"
gem "shoulda-matchers"
gem "timecop"
gem "webmock"
end
Loading

0 comments on commit 2359829

Please sign in to comment.