-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
200 additions
and
18 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.1.2 | ||
3.2.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Global build args | ||
ARG GIT_SHA=unspecified | ||
ARG RACK_ENV=production | ||
|
||
# Build image | ||
FROM ruby:3.2.2-alpine as BUILD_IMAGE | ||
|
||
# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#using-pipes | ||
SHELL ["/bin/ash", "-eo", "pipefail", "-c"] | ||
|
||
# https://docs.docker.com/build/cache/#use-the-dedicated-run-cache | ||
RUN --mount=type=cache,target=/var/cache/apk \ | ||
apk add --no-cache build-base | ||
|
||
ENV APP_HOME /app | ||
|
||
RUN mkdir $APP_HOME | ||
WORKDIR $APP_HOME | ||
|
||
COPY Gemfile* $APP_HOME/ | ||
|
||
# Run bundler in deployment mode | ||
RUN bundle config set deployment 'true' && \ | ||
bundle config set without 'development test' && \ | ||
bundle config set path 'vendor/bundle' | ||
|
||
# Install gems and remove unnecessary files | ||
RUN MAKE="make --jobs $(($(nproc)+1))" bundle install --jobs "$(nproc)" --retry 3 \ | ||
&& rm -rf vendor/bundle/ruby/*/cache/*.gem \ | ||
&& find vendor/bundle/ruby/*/gems/ -type f -name "*.c" -delete \ | ||
&& find vendor/bundle/ruby/*/gems/ -type f -name "*.o" -delete \ | ||
&& find vendor/bundle/ruby/*/gems/ -type f -name "*.md" -delete \ | ||
&& find vendor/bundle/ruby/*/gems/ -name "test" -type d -exec rm -rf {} + \ | ||
&& find vendor/bundle/ruby/*/gems/ -name "spec" -type d -exec rm -rf {} + | ||
|
||
COPY . $APP_HOME | ||
|
||
# Final image | ||
FROM ruby:3.2.2-alpine | ||
|
||
ARG GIT_SHA | ||
ARG RACK_ENV | ||
|
||
LABEL git-sha=${GIT_SHA} | ||
|
||
RUN adduser -D --uid 1001 ruby | ||
USER 1001 | ||
|
||
ENV APP_HOME /home/ruby | ||
WORKDIR $APP_HOME | ||
|
||
# Copy the app from the BUILD_IMAGE | ||
COPY --from=BUILD_IMAGE --chown=ruby /app $APP_HOME | ||
|
||
# Copy the bundle configuration from the BUILD_IMAGE | ||
COPY --from=BUILD_IMAGE --chown=ruby $BUNDLE_APP_CONFIG/config $BUNDLE_APP_CONFIG/config | ||
|
||
ENV RACK_ENV=${RACK_ENV} \ | ||
GIT_SHA=${GIT_SHA} \ | ||
REQUIRE_DOTENV=false | ||
|
||
EXPOSE 9292 | ||
|
||
CMD ["bundle", "exec", "puma", "-e", "production"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ DEPENDENCIES | |
sinatra (~> 2.2) | ||
|
||
RUBY VERSION | ||
ruby 3.1.2p20 | ||
ruby 3.2.2p53 | ||
|
||
BUNDLED WITH | ||
2.3.12 | ||
2.4.19 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
require 'sinatra' | ||
require_relative 'answer_randomizer' | ||
|
||
get '/' do | ||
@answer = AnswerRandomizer.random_answer | ||
class App < Sinatra::Base | ||
get '/' do | ||
@answer = AnswerRandomizer.random_answer | ||
|
||
erb :index | ||
end | ||
erb :index | ||
end | ||
|
||
get '/ruby.png' do | ||
send_file 'ruby.png' | ||
get '/ruby.png' do | ||
send_file 'ruby.png' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
require './app' | ||
|
||
run App |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
apiVersion: v1 | ||
data: | ||
APP_ENV: production | ||
PORT: "9292" | ||
RACK_ENV: production | ||
APP_URL: "https://is-ruby-dead.pbstriker38.dev/" | ||
kind: ConfigMap | ||
metadata: | ||
name: is-ruby-dead | ||
namespace: default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: is-ruby-dead | ||
namespace: default | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: is-ruby-dead | ||
app.kubernetes.io/name: is-ruby-dead | ||
version: v1.0.0 | ||
name: is-ruby-dead | ||
namespace: default | ||
spec: | ||
progressDeadlineSeconds: 600 | ||
replicas: 1 | ||
revisionHistoryLimit: 10 | ||
selector: | ||
matchLabels: | ||
app: is-ruby-dead | ||
strategy: | ||
rollingUpdate: | ||
maxSurge: 25% | ||
maxUnavailable: 25% | ||
type: RollingUpdate | ||
template: | ||
metadata: | ||
labels: | ||
app: is-ruby-dead | ||
app.kubernetes.io/name: is-ruby-dead | ||
version: v1.0.0 | ||
spec: | ||
securityContext: | ||
seccompProfile: | ||
type: RuntimeDefault | ||
containers: | ||
- name: web | ||
envFrom: | ||
- configMapRef: | ||
name: is-ruby-dead | ||
- secretRef: | ||
name: is-ruby-dead | ||
image: pbstriker38/is-ruby-dead:v1.0.0 | ||
imagePullPolicy: IfNotPresent | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
runAsNonRoot: true | ||
capabilities: | ||
drop: ["ALL"] | ||
ports: | ||
- containerPort: 9292 | ||
protocol: TCP | ||
resources: | ||
limits: | ||
memory: 200Mi | ||
requests: | ||
cpu: 50m | ||
memory: 100Mi | ||
terminationMessagePath: /dev/termination-log | ||
terminationMessagePolicy: File | ||
dnsPolicy: ClusterFirst | ||
restartPolicy: Always | ||
schedulerName: default-scheduler | ||
serviceAccount: is-ruby-dead | ||
serviceAccountName: is-ruby-dead | ||
terminationGracePeriodSeconds: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: is-ruby-dead | ||
namespace: default | ||
annotations: | ||
cert-manager.io/cluster-issuer: "letsencrypt-prod" | ||
spec: | ||
ingressClassName: nginx | ||
rules: | ||
- host: is-ruby-dead.pbstriker38.dev | ||
http: | ||
paths: | ||
- pathType: Prefix | ||
backend: | ||
service: | ||
name: is-ruby-dead | ||
port: | ||
number: 80 | ||
path: / | ||
tls: | ||
- hosts: | ||
- is-ruby-dead.pbstriker38.dev | ||
secretName: is-ruby-dead-tls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: is-ruby-dead | ||
namespace: default | ||
spec: | ||
ports: | ||
- name: http | ||
port: 80 | ||
protocol: TCP | ||
targetPort: 9292 | ||
selector: | ||
app: is-ruby-dead | ||
type: ClusterIP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters