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

Updates to dockerfile and chart. #71

Closed
wants to merge 1 commit 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
7 changes: 1 addition & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker.io/ruby:2.6-bullseye
FROM docker.io/ruby:3.2-bookworm

# Needed by Ruby to process UTF8-encoded files
ENV LANG C.UTF-8
Expand All @@ -13,21 +13,16 @@ RUN set -eus; \
libpq-dev \
libxml2-dev \
libxslt1-dev \
libjemalloc2 \
postgresql-client \
iputils-ping \
net-tools \
netcat \
htop \
strace \
pg-activity \
; \
apt-get clean; \
rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/*;

# @see https://engineering.binti.com/jemalloc-with-ruby-and-docker/
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2

WORKDIR /app
COPY Gemfile Gemfile.lock ./
ENV RAILS_ENV="${RAIL_ENV:-"production"}"
Expand Down
6 changes: 3 additions & 3 deletions deployment/chart/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 11.9.13
digest: sha256:a8b5a970ef7b5fc6e29eae603b8d07ffe64b813c71c4f9aef75c22ab03effdd0
generated: "2023-03-19T19:00:12.512904794-07:00"
version: 14.3.3
digest: sha256:99ed07cbbb8aba1fbfbf954092ace9cea5d83ad3b269a91042d2eed004f4eb12
generated: "2024-03-12T18:59:13.664349161-07:00"
2 changes: 1 addition & 1 deletion deployment/chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ appVersion: "3.0.0"

dependencies:
- name: postgresql
version: "11"
version: "14"
repository: "https://charts.bitnami.com/bitnami"
10 changes: 7 additions & 3 deletions deployment/chart/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "chart.fullname" . }}
Expand All @@ -17,12 +17,16 @@ spec:
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
target:
type: AverageValue
averageValue: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ services:
- '3000:3000'

postgres:
image: 'postgres:11-alpine'
image: 'postgres:14-alpine'
environment:
- POSTGRES_USER=ticket
- POSTGRES_PASSWORD=ticket
Expand Down
34 changes: 1 addition & 33 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,6 @@

set -e

if [[ -z $RAILS_ENV ]]; then
echo "Please set RAILS_ENV before invoking this script."
exit 1
fi

# Discourse Settings to optimize Garbage Collection
export RUBY_GC_HEAP_INIT_SLOTS=997339
export RUBY_GC_HEAP_FREE_SLOTS=626600
export RUBY_GC_HEAP_GROWTH_FACTOR=1.03
export RUBY_GC_HEAP_GROWTH_MAX_SLOTS=88792
export RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=2.4
export RUBY_GC_MALLOC_LIMIT=34393793
export RUBY_GC_MALLOC_LIMIT_MAX=41272552
export RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR=1.32
export RUBY_GC_OLDMALLOC_LIMIT=39339204
export RUBY_GC_OLDMALLOC_LIMIT_MAX=47207045
export RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR=1.2

# https://www.mikeperham.com/2018/04/25/taming-rails-memory-bloat/
export MALLOC_ARENA_MAX=2

if [[ ${RAILS_ENV} == "production" ]]; then
export DATABASE_URL="postgres://${TICKET_DB_USER}:${TICKET_DB_PASSWORD}@${TICKET_DB_HOST}:${TICKET_DB_PORT}/${TICKET_DB_NAME}?"
fi
# This may be a problem if we run more than one pod
# possible solution — adds an arbitrary delay before running it
# delay="$(( RANDOM / 500 ))" ; sleep ${delay} && bundle exec rake db:migrate
bundle exec rake db:migrate

if [[ "$DB_SEED" = "true" ]]; then
echo "seeding the DB"
bundle exec rake db:seed
fi
export DATABASE_URL="postgres://${TICKET_DB_USER}:${TICKET_DB_PASSWORD}@${TICKET_DB_HOST}:${TICKET_DB_PORT}/${TICKET_DB_NAME}?"

bundle exec rails s -p 3000 -b '0.0.0.0'
Loading