-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c1d333
commit c671822
Showing
21 changed files
with
419 additions
and
63 deletions.
There are no files selected for viewing
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,34 @@ | ||
FROM ruby:2.5.0-alpine as builder | ||
|
||
# Pg | ||
RUN apk --update --upgrade add postgresql-dev nodejs git build-base libffi-dev libgcc | ||
RUN npm install -g bower | ||
RUN echo '{ "allow_root": true }' > /root/.bowerrc | ||
|
||
ENV APP_ROOT /app | ||
RUN mkdir $APP_ROOT | ||
WORKDIR $APP_ROOT | ||
|
||
# Bundle | ||
COPY . /app | ||
RUN gem update bundler && bundle install --jobs 4 && rm -rf /usr/local/bundle/cache/*.gem \ | ||
&& find /usr/local/bundle/gems/ -name "*.c" -delete \ | ||
&& find /usr/local/bundle/gems/ -name "*.o" -delete | ||
|
||
# Run bower | ||
WORKDIR $APP_ROOT/public | ||
RUN bower install | ||
|
||
FROM ruby:2.5.0-alpine | ||
|
||
#Pg | ||
RUN apk --update --upgrade add postgresql-dev && rm -rf /var/cache/apk/* | ||
|
||
ENV APP_ROOT /app | ||
RUN mkdir $APP_ROOT | ||
WORKDIR $APP_ROOT | ||
|
||
COPY --from=builder /usr/local/bundle /usr/local/bundle | ||
COPY --from=builder /app /app | ||
|
||
EXPOSE 3000 |
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
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,14 +1,16 @@ | ||
#!/usr/bin/env bash | ||
|
||
UNIXTIME=$(date +%s) | ||
|
||
cd ./front | ||
docker build -f Dockerfile -t sergkoba/blog:latest . | ||
docker push sergkoba/blog:latest | ||
docker build -f Dockerfile.prod -t repo.treescale.com/skoba/blog:build-$UNIXTIME . | ||
docker push repo.treescale.com/skoba/blog:build-$UNIXTIME | ||
|
||
cd ../admin | ||
docker build -f Dockerfile -t sergkoba/blog:latest-admin . | ||
docker push sergkoba/blog:latest-admin | ||
docker build -f Dockerfile.prod -t repo.treescale.com/skoba/blog-admin:build-$UNIXTIME . | ||
docker push repo.treescale.com/skoba/blog-admin:build-$UNIXTIME | ||
|
||
cd .. | ||
rancher up -d -u -c -p | ||
|
||
rancher exec admin bundle exec ./cli db_migrate | ||
rancher exec front bundle exec ./cli sitemap_generate | ||
helm upgrade -i --set image.tag=build-$UNIXTIME --wait --namespace default blog ./chart | ||
ADMIN_POD=$(kubectl get pods -l app.kubernetes.io/name=blog-admin --output=jsonpath={.items..metadata.name}) | ||
kubectl exec $ADMIN_POD bundle exec ./cli db_migrate |
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,21 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj |
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 @@ | ||
apiVersion: v1 | ||
appVersion: "1.0" | ||
description: A Helm chart for 1devblog | ||
name: blog | ||
version: 0.1.0 |
Empty file.
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,32 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "chart.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "chart.fullname" -}} | ||
{{- if .Values.fullnameOverride -}} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} | ||
{{- else -}} | ||
{{- $name := default .Chart.Name .Values.nameOverride -}} | ||
{{- if contains $name .Release.Name -}} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" -}} | ||
{{- else -}} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "chart.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} | ||
{{- 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,50 @@ | ||
apiVersion: apps/v1beta2 | ||
kind: Deployment | ||
metadata: | ||
name: "{{ include "chart.fullname" . }}-admin-deployment" | ||
labels: | ||
app.kubernetes.io/name: "{{ include "chart.name" . }}-admin" | ||
helm.sh/chart: {{ include "chart.chart" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
spec: | ||
replicas: {{ .Values.replicaCount }} | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: "{{ include "chart.name" . }}-admin" | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: "{{ include "chart.name" . }}-admin" | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
spec: | ||
containers: | ||
- name: "{{ .Chart.Name }}-admin" | ||
image: "{{ .Values.image.repository }}-admin:{{ .Values.image.tag }}" | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
command: ["rackup", "--port", "3000", "--host", "0.0.0.0"] | ||
env: | ||
- name: RACK_ENV | ||
value: "production" | ||
- name: POSTGRES_HOST | ||
value: "{{ .Chart.Name }}-postgres-service" | ||
envFrom: | ||
- secretRef: | ||
name: "{{ include "chart.name" . }}-postgres-secret" | ||
- secretRef: | ||
name: "{{ include "chart.name" . }}-api-secret" | ||
ports: | ||
- name: http | ||
containerPort: 3000 | ||
protocol: TCP | ||
livenessProbe: | ||
httpGet: | ||
path: / | ||
port: http | ||
readinessProbe: | ||
httpGet: | ||
path: / | ||
port: http | ||
imagePullSecrets: | ||
- name: regcred |
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,19 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: "{{ include "chart.fullname" . }}-admin-service" | ||
labels: | ||
app.kubernetes.io/name: "{{ include "chart.name" . }}-admin-service" | ||
helm.sh/chart: {{ include "chart.chart" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
spec: | ||
type: {{ .Values.service.type }} | ||
ports: | ||
- port: {{ .Values.service.port }} | ||
targetPort: 3000 | ||
protocol: TCP | ||
name: http | ||
selector: | ||
app.kubernetes.io/name: "{{ include "chart.name" . }}-admin" | ||
app.kubernetes.io/instance: {{ .Release.Name }} |
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,12 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: "{{ include "chart.name" . }}-api-secret" | ||
labels: | ||
app.kubernetes.io/name: "{{ include "chart.name" . }}-api-secret" | ||
helm.sh/chart: {{ include "chart.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
type: Opaque | ||
data: | ||
API_TOKEN: "RnJPTU9SMlhKTlNCMVloeDFNRDRDNGt0NGRTek1lRDQ=" |
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,50 @@ | ||
apiVersion: apps/v1beta2 | ||
kind: Deployment | ||
metadata: | ||
name: "{{ include "chart.fullname" . }}-front-deployment" | ||
labels: | ||
app.kubernetes.io/name: "{{ include "chart.name" . }}-front" | ||
helm.sh/chart: {{ include "chart.chart" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
spec: | ||
replicas: {{ .Values.replicaCount }} | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: "{{ include "chart.name" . }}-front" | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: "{{ include "chart.name" . }}-front" | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
spec: | ||
containers: | ||
- name: "{{ .Chart.Name }}-front" | ||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
command: ["rackup", "--port", "3001", "--host", "0.0.0.0"] | ||
env: | ||
- name: RACK_ENV | ||
value: "production" | ||
- name: POSTGRES_HOST | ||
value: "{{ .Chart.Name }}-postgres-service" | ||
envFrom: | ||
- secretRef: | ||
name: "{{ include "chart.name" . }}-postgres-secret" | ||
- secretRef: | ||
name: "{{ include "chart.name" . }}-api-secret" | ||
ports: | ||
- name: http | ||
containerPort: 3001 | ||
protocol: TCP | ||
livenessProbe: | ||
httpGet: | ||
path: / | ||
port: http | ||
readinessProbe: | ||
httpGet: | ||
path: / | ||
port: http | ||
imagePullSecrets: | ||
- name: regcred |
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,19 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: "{{ include "chart.fullname" . }}-front-service" | ||
labels: | ||
app.kubernetes.io/name: "{{ include "chart.name" . }}-front-service" | ||
helm.sh/chart: {{ include "chart.chart" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
spec: | ||
type: {{ .Values.service.type }} | ||
ports: | ||
- port: {{ .Values.service.port }} | ||
targetPort: 3001 | ||
protocol: TCP | ||
name: http | ||
selector: | ||
app.kubernetes.io/name: "{{ include "chart.name" . }}-front" | ||
app.kubernetes.io/instance: {{ .Release.Name }} |
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,54 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: "{{ include "chart.fullname" . }}-postgres-service" | ||
labels: | ||
app.kubernetes.io/name: "{{ include "chart.name" . }}-postgres-service" | ||
helm.sh/chart: {{ include "chart.chart" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
spec: | ||
ports: | ||
- port: 5432 | ||
selector: | ||
app.kubernetes.io/name: "{{ include "chart.name" . }}-postgres" | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
--- | ||
apiVersion: apps/v1beta2 | ||
kind: Deployment | ||
metadata: | ||
name: "{{ include "chart.fullname" . }}-postgres-deployment" | ||
labels: | ||
app.kubernetes.io/name: "{{ include "chart.name" . }}-postgres" | ||
helm.sh/chart: {{ include "chart.chart" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
spec: | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: "{{ include "chart.name" . }}-postgres" | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
strategy: | ||
type: Recreate | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: "{{ include "chart.name" . }}-postgres" | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
spec: | ||
containers: | ||
- image: postgres:11.1 | ||
name: "{{ .Chart.Name }}-postgres" | ||
ports: | ||
- containerPort: 5432 | ||
name: postgres | ||
volumeMounts: | ||
- name: "{{ include "chart.name" . }}-postgres-persistent-storage" | ||
mountPath: /var/lib/postgresql/data | ||
envFrom: | ||
- secretRef: | ||
name: "{{ include "chart.name" . }}-postgres-secret" | ||
volumes: | ||
- name: "{{ include "chart.name" . }}-postgres-persistent-storage" | ||
persistentVolumeClaim: | ||
claimName: "{{ include "chart.name" . }}-postgres-pv-claim" |
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,35 @@ | ||
kind: PersistentVolume | ||
apiVersion: v1 | ||
metadata: | ||
name: "{{ include "chart.name" . }}-postgres-pv-volume" | ||
labels: | ||
type: local | ||
app.kubernetes.io/name: "{{ include "chart.name" . }}-postgres-pv-volume" | ||
helm.sh/chart: {{ include "chart.chart" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
spec: | ||
storageClassName: manual | ||
capacity: | ||
storage: 3Gi | ||
accessModes: | ||
- ReadWriteOnce | ||
hostPath: | ||
path: "/mnt/data" | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: "{{ include "chart.name" . }}-postgres-pv-claim" | ||
labels: | ||
app.kubernetes.io/name: "{{ include "chart.name" . }}-postgres-pv-claim" | ||
helm.sh/chart: {{ include "chart.chart" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
spec: | ||
storageClassName: manual | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 3Gi |
Oops, something went wrong.