Skip to content

Commit

Permalink
[Upgrade] Rails 4.2 → 7.1 By Generating a Rails7 App + TicketingApp f…
Browse files Browse the repository at this point in the history
…iles (#72)
  • Loading branch information
kigster authored Apr 19, 2024
1 parent aab3078 commit adbed3a
Show file tree
Hide file tree
Showing 338 changed files with 18,632 additions and 3,918 deletions.
14 changes: 14 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
ARG RUBY_VERSION=3.2.2
FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION

# Install packages needed to build gems
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y \
libpq-dev libvips \
# For video thumbnails
ffmpeg \
# For pdf thumbnails. If you want to use mupdf instead of poppler,
# you can install the following packages instead:
# mupdf mupdf-tools
poppler-utils
50 changes: 50 additions & 0 deletions .devcontainer/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
services:
rails-app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile

volumes:
- ../..:/workspaces:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

networks:
- default

# Uncomment the next line to use a non-root user for all processes.
# user: vscode

# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)
ports:
- 45678:45678
depends_on:
- redis
- postgres


redis:
image: redis:7.2
restart: unless-stopped
networks:
- default
volumes:
- redis-data:/data

postgres:
image: postgres:16.1
restart: unless-stopped
networks:
- default
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres


volumes:
redis-data:
postgres-data:
30 changes: 30 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby
{
"name": "ticket_booth",
"dockerComposeFile": "compose.yaml",
"service": "rails-app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {}
},

"containerEnv": {
"REDIS_URL": "redis://redis:6379/1",
"DB_HOST": "postgres"
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root",

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "bin/setup"
}
10 changes: 0 additions & 10 deletions .env

This file was deleted.

22 changes: 22 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# vim: ft=bash

PATH_add bin
PATH_add /opt/homebrew/bin

export VOLTA_HOME=${HOME}/.volta
PATH_add ${VOLTA_HOME}/bin

export brew_prefix="$(brew --prefix)"

pg_pkg="postgresql@$(cat .postgresql-version)"
pg_dir="$(brew --prefix "${pg_pkg}")/bin/"

[[ -d ${pg_dir} ]] && PATH_add "${pg_dir}"

export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

export V8HOME=$(brew --prefix [email protected])

export CFLAGS="-Wno-error=implicit-function-declaration -Wno-error=no-compound-token-split-by-macro"
export CPPFLAGS="$CPPFLAGS -I ${brew_prefix}/include -I ${V8HOME}/include"
export LDFLAGS="$LDFLAGS -L ${brew_prefix}/lib -L ${V8HOME}/lib"

export RUBY_CPPFLAGS="$CPPFLAGS"
export RUBY_CFLAGS="$CFLAGS"

[[ -f .envrc.local ]] && source .envrc.local
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# See https://git-scm.com/docs/gitattributes for more about git attribute files.

# Mark the database schema as having been generated.
db/schema.rb linguist-generated

# Mark any vendored files as having been vendored.
vendor/* linguist-vendored
config/credentials/*.yml.enc diff=rails_credentials
config/credentials.yml.enc diff=rails_credentials
35 changes: 0 additions & 35 deletions .github/CODEOWNERS

This file was deleted.

12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: bundler
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
6 changes: 1 addition & 5 deletions .github/workflows/bash.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
check_together: 'yes'
scandir: './bin'
ignore_names: init.sh
run: bin/shchk
permissions:
checks: read
contents: read
Expand Down
41 changes: 0 additions & 41 deletions .github/workflows/build.yaml

This file was deleted.

63 changes: 63 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Create and publish a Docker image

on:
push:
branches: [ 'release', 'releases/**']
workflow_dispatch:
inputs:
branch:
description: 'Branch to build'
required: true
default: 'main'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}


jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.branch || github.ref }}

# login-action v3.1.0
- name: Log in to the Container registry
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# metadata-action v5.5.1
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# In order to support deploying multiple versions that don't stomp on
# each other some new tagging rules are created.
# The tagging below follows:
# - When a properly formatted tag is created, as in a release, put the semver version x.y.z in the tag
# - If a build is triggered manually, then mark the branch and short sha in the tag
# - When the default branch is updated, create a release candiate tag
tags: |
type=semver,pattern={{version}}
type=sha,prefix={{branch || tag}}-{{sha}},event=workflow_dispatch
type=raw,value={{date 'YYYYMMDD-HHmm' tz='America/Los_Angeles'}}-rc,event=branch,branch={{is_default_branch}}
# build-push-action v5.3.0
- name: Build and push Docker image
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
69 changes: 69 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
name: DeployToGKE
concurrency: production

on:
release:
types:
- created
push:
branches:
- 'releases/*'
tags:
- '*-rc'
workflow_dispatch:
inputs:
containerTag:
required: true
description: 'The docker tag for a container already in GCP'

env:
GCP_REGION: us-central1
GKE_CLUSTER_NAME: fnf-apps

jobs:
deploy:
name: TicketBoothDeploy
runs-on: ubuntu-latest
environment: ${{ vars.ENVIRONMENT }}
permissions:
contents: 'read'
id-token: 'write'
steps:
# This step is only required because the Helm chart is in this repo
- id: checkout
name: TicketBooth checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == "workflow_dispatch" && 'main' || github.ref }}
fetch-depth: 1

- id: gcpAuth
uses: google-github-actions/auth@v2
with:
workload_identity_provider: "projects/${{ vars.GCP_PROJECT_ID }}/locations/global/workloadIdentityPools"
service_account: ${{ vars.GCP_SERVICE_ACCOUNT_ID }}

- id: gkeLogin
name: GKE Login
uses: google-github-actions/get-gke-credentials@v2
with:
cluster_name: ${{ env.GKE_CLUSTER_NAME }}
location: ${{ env.GCP_REGION }}

- id: runHelm
name: Helm Update
uses: deliverybot/helm@v1
with:
release: ${{ vars.HELM_RELEASE }}
namespace: default
chart: deployment/chart
token: ${{ github.token }}
values: |
image.tag: ${{ github.event_name == "workflow_dispatch" && inputs.containerTag || github.ref_name }}
value-files: >-
[
"deployment/env/base.yaml",
"deployment/${{ environment }}.yaml"
]
atomic: ${{ github.event_name == "workflow_dispatch" && false || true }}
Loading

0 comments on commit adbed3a

Please sign in to comment.