Skip to content

Commit e711ce3

Browse files
committed
storage saved to local disk, docker builds to github, added disable registration
1 parent 5e78973 commit e711ce3

File tree

7 files changed

+86
-21
lines changed

7 files changed

+86
-21
lines changed

.github/workflows/docker.yml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,49 @@
1-
name: Build and Push Docker Image
1+
name: Auto-tag and Docker Build
22

33
on:
44
push:
55
branches: [master]
66

77
jobs:
8-
docker:
8+
tag:
99
runs-on: ubuntu-latest
10+
outputs:
11+
new_tag: ${{ steps.tag.outputs.new_tag }}
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
1015

16+
- name: Bump version and push tag
17+
id: tag
18+
uses: mathieudutour/[email protected]
19+
with:
20+
github_token: ${{ secrets.GITHUB_TOKEN }}
21+
default_bump: patch
22+
tag_prefix: v
23+
24+
docker:
25+
needs: tag
26+
runs-on: ubuntu-latest
1127
steps:
1228
- name: Checkout code
1329
uses: actions/checkout@v3
1430

1531
- name: Set up Docker Buildx
1632
uses: docker/setup-buildx-action@v3
1733

18-
- name: Log in to Docker Hub
34+
- name: Log in to GitHub Container Registry
1935
uses: docker/login-action@v3
2036
with:
21-
username: ${{ secrets.DOCKER_USERNAME }}
22-
password: ${{ secrets.DOCKER_PASSWORD }}
37+
registry: ghcr.io
38+
username: ${{ github.actor }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
2340

2441
- name: Build and push Docker image
2542
uses: docker/build-push-action@v5
2643
with:
2744
context: .
2845
push: true
29-
tags: iteratorpm/iterator:latest
46+
platforms: linux/amd64,linux/arm64
47+
tags: |
48+
ghcr.io/iteratorpm/iterator:latest
49+
ghcr.io/iteratorpm/iterator:${{ needs.tag.outputs.new_tag }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ docker run -d \
8383
-p 3000:3000 \
8484
-e [email protected]:password \
8585
-v ./iterator-db:/usr/src/app/storage \
86-
iteratorpm/iterator:latest
86+
ghcr.io/iteratorpm/iterator:latest
8787
```
8888

8989
Visit `http://localhost:3000` with demo credentials:

app/models/user.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,18 @@ def self.ransackable_associations(auth_object = nil)
3636
belongs_to :current_organization, class_name: 'Organization', optional: true
3737

3838
# Include default devise modules. Others available are:
39-
devise :invitable, :database_authenticatable, :registerable,
40-
:recoverable, :rememberable, :validatable, :confirmable
39+
devise_modules = [
40+
:invitable,
41+
:database_authenticatable,
42+
:recoverable,
43+
:rememberable,
44+
:validatable,
45+
:confirmable
46+
]
47+
48+
devise_modules << :registerable unless ENV["DISABLE_REGISTRATION"] == "true"
49+
50+
devise(*devise_modules)
4151

4252
validates :name, length: { minimum: 1, maximum: 30 }
4353
validates :username, length: { minimum: 1, maximum: 30 }

app/views/layouts/_header.html.slim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ header.bg-white.shadow-sm
4545

4646
= button_to "Sign Out", destroy_user_session_path, method: :delete, class: "block w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100", role: "menuitem", tabindex: "-1", data: { aid: "ProfileDropdown__signout" }
4747
- else
48-
span.text-gray-600 Don't have an account?
49-
a.ml-2.text-blue-600.font-medium.hover:text-blue-800 href=new_user_registration_path SIGN UP
48+
- if devise_mapping.registerable? && controller_name != 'registrations'
49+
span.text-gray-600 Don't have an account?
50+
a.ml-2.text-blue-600.font-medium.hover:text-blue-800 href=new_user_registration_path SIGN UP
5051

config/routes.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Rails.application.routes.draw do
2-
devise_for :users
2+
if ENV["DISABLE_REGISTRATION"] == "true"
3+
devise_for :users, skip: [:registrations]
4+
else
5+
devise_for :users
6+
end
37

48
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
59
# Can be used by load balancers and uptime monitors to verify that the app is live.

config/storage.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ local:
66
service: Disk
77
root: <%= Rails.root.join("storage") %>
88

9+
production:
10+
service: Disk
11+
root: <%= Rails.root.join("storage") %>
12+
913
# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
1014
# amazon:
1115
# service: S3

docker-compose.yml

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,50 @@
11
version: '3.8'
22
services:
3-
db:
4-
image: postgres:17
3+
iterator-db:
4+
image: postgres:17-alpine
5+
restart: always
56
environment:
67
POSTGRES_USER: postgres
78
POSTGRES_PASSWORD: password
89
POSTGRES_DB: iterator
10+
networks:
11+
- iterator-network
912
volumes:
10-
- pgdata:/var/lib/postgresql/data
13+
- postgres-volume:/var/lib/postgresql/data
1114

12-
web:
15+
iterator-web:
1316
image: iteratorpm/iterator:latest
17+
restart: always
1418
environment:
15-
DATABASE_URL: postgres://postgres:password@db/iterator
19+
DATABASE_URL: postgres://postgres:password@db:5432/iterator
20+
RAILS_ENV: production
21+
RAILS_LOG_TO_STDOUT: true
22+
RAILS_SERVE_STATIC_FILES: true
23+
SECRET_KEY_BASE: "replace this with random characters!"
24+
APP_HOST: yourwebsite.com
25+
APP_PROTOCOL: https
26+
DISABLE_REGISTRATION: "false"
27+
SMTP_ADDRESS: smtp.yourprovider.com
28+
SMTP_PORT: 587
29+
SMTP_USER_NAME: your_username
30+
SMTP_PASSWORD: your_password
31+
DEFAULT_FROM_EMAIL: [email protected]
32+
volumes:
33+
- storage-volume:/usr/src/app/storage
1634
depends_on:
17-
- db
35+
- iteraotr-db
1836
ports:
1937
- "3000:3000"
20-
env_file:
21-
- .env
38+
networks:
39+
- iterator-network
2240

2341
volumes:
24-
pgdata:
42+
postgres-volume:
43+
external: false
44+
45+
storage-volume:
46+
external: false
47+
48+
networks:
49+
iterator-network:
50+
external: false

0 commit comments

Comments
 (0)