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

Created docker-compose configuration and tested in local to run as container #416

Closed
wants to merge 6 commits into from
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
28 changes: 28 additions & 0 deletions .github/workflows/create-docker-image-push-toghcr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build and Push Docker Image

on:
push:
branches:
- main

Choose a reason for hiding this comment

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

Wouldn't it suffice to only build and push on creating tags?


jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Docker image
run: docker build -t ghcr.io/${{ github.repository }}/maybe:latest .

- name: Push Docker image to GHCR
run: |
docker push ghcr.io/${{ github.repository }}/maybe:latest
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the Dockerfile that we're pushing here build for you locally? I think we may be a bit early to start pushing to ghcr as we have a lot of services to still add.

10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ Please visit our [Linux dev setup guide](https://github.com/maybe-finance/maybe/

Please visit our [Windows dev setup guide](https://github.com/maybe-finance/maybe/wiki/Windows-Dev-Setup-Guide).

#### Docker Container

```
docker-compose up -d
```
Application will be running on [http://localhost:3000](http://localhost:3000)

>NOTE: SSL_ENABLE default value is `true`, when you run as container without SSL certs it fails to serve on http, so set it to `false` running as container.


### Testing Emails

In development, we use `letter_opener` to automatically open emails in your browser. When an email sends locally, a new browser tab will open with a preview.
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
# config.assume_ssl = true

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true
config.force_ssl = ENV.fetch("SSL_ENABLE", "true") == "true"

Choose a reason for hiding this comment

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

I would suggest using either SSL_ENABLED or ENABLE_SSL and keeping it consistent for the upcoming env vars

Copy link
Author

Choose a reason for hiding this comment

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

You want me to have the variable ENABLE_SSL confused. Please let me know I can update

Choose a reason for hiding this comment

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

ENABLE_SSL or SSL_ENABLED => OK

SSL_ENABLE => NOT OK

Copy link
Collaborator

Choose a reason for hiding this comment

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

If possible, can we stick with this solution?


# Log to STDOUT by default
config.logger = ActiveSupport::Logger.new(STDOUT)
Expand Down
39 changes: 39 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: '3.8'

services:
postgres:
image: postgres:16.1
container_name: postgres_db
networks: ["maybe"]
volumes:
- maybe_postgresql:/var/lib/postgresql/data/
environment:
POSTGRES_USER: maybe
POSTGRES_PASSWORD: maybepass
POSTGRES_DB: maybedb
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U $${POSTGRES_USER}']
interval: 5s
timeout: 5s
retries: 10
ports: ["5432:5432"]

maybe:
image: ghcr.io/maybe-finance/maybe:latest
Copy link
Collaborator

Choose a reason for hiding this comment

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

This docker-compose file will be used in development, so I'm not sure if we want to reference our official image as it will be optimized for production. Was that the intention here?

container_name: maybe
networks: ["maybe"]
ports: ["3000:3000"]
environment:
SECRET_KEY_BASE: maybemaybehash
MAYBE_DATABASE_PASSWORD: maybepass
SSL_ENABLE: false
RAILS_MAX_THREADS: 5 #optional
DB_HOST: postgres
POSTGRES_USER: maybe
POSTGRES_DB: maybedb
depends_on:
- postgres
volumes:
maybe_postgresql:
networks:
maybe: