Skip to content

Commit

Permalink
docker container working, setting up k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
Rio Sinnott committed Feb 13, 2025
1 parent 31f308d commit 384d024
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 17 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ RUN apt-get update -qq && \
apt-get install -y \
build-essential \
libpq-dev \
postgresql-client \
nodejs \
git \
curl \
Expand Down
31 changes: 14 additions & 17 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,26 @@
# Skip http-to-https redirect for the default health check endpoint.
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }

# Log to STDOUT with the current request id as a default log tag.
config.log_tags = [ :request_id ]
# Log to STDOUT by default
config.logger = ActiveSupport::Logger.new(STDOUT)
config.logger.formatter = config.log_formatter
config.logger.formatter = Logger::Formatter.new
config.log_tags = [:request_id]
config.logger = ActiveSupport::TaggedLogging.new(config.logger)

# Change to "debug" to log everything (including potentially personally-identifiable information!)
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")

# Prevent health checks from clogging up the logs.
config.silence_healthcheck_path = "/up"
config.middleware.insert_before 0, Rack::Runtime do |app|
path = "/up"
->(env) {
if env["PATH_INFO"] == path
[200, {}, []]
else
app.call(env)
end
}
end

# Don't log any deprecations.
config.active_support.report_deprecations = false
Expand All @@ -58,25 +67,13 @@
# Set host to be used by links generated in mailer templates.
config.action_mailer.default_url_options = { host: "example.com" }

# Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit.
# config.action_mailer.smtp_settings = {
# user_name: Rails.application.credentials.dig(:smtp, :user_name),
# password: Rails.application.credentials.dig(:smtp, :password),
# address: "smtp.example.com",
# port: 587,
# authentication: :plain
# }

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true

# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false

# Only use :id for inspections in production.
config.active_record.attributes_for_inspect = [ :id ]

# Enable DNS rebinding protection and other `Host` header attacks.
# config.hosts = [
# "example.com", # Allow requests from example.com
Expand All @@ -85,4 +82,4 @@
#
# Skip DNS rebinding protection for the default health check endpoint.
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
end
end
62 changes: 62 additions & 0 deletions k8s/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: amenity-app
labels:
app: amenity
spec:
replicas: 2
selector:
matchLabels:
app: amenity
template:
metadata:
labels:
app: amenity
spec:
containers:
- name: amenity
image: riocodes/amenity:1.0
ports:
- containerPort: 3000
env:
- name: RAILS_ENV
value: "production"
- name: DATABASE_HOST
value: 192.168.66.9
- name: DATABASE_USER
valueFrom:
secretKeyRef:
name: amenity-secrets
key: database-user
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: amenity-secrets
key: database-password
- name: DATABASE_NAME
value: "amenity_production"
- name: RAILS_MASTER_KEY
valueFrom:
secretKeyRef:
name: amenity-secrets
key: rails-master-key
resources:
requests:
memory: "512Mi"
cpu: "250m"
limits:
memory: "1Gi"
cpu: "500m"
readinessProbe:
httpGet:
path: /
port: 3000
initialDelaySeconds: 10
periodSeconds: 5
livenessProbe:
httpGet:
path: /
port: 3000
initialDelaySeconds: 15
periodSeconds: 10

0 comments on commit 384d024

Please sign in to comment.