Skip to content

Commit 37cc10b

Browse files
author
Keith Thompson
authored
Merge pull request #15 from coderjourney/front-end-deployment
Create Nginx frontend service for the rails application
2 parents 5d14481 + f187e06 commit 37cc10b

File tree

4 files changed

+73
-1
lines changed

4 files changed

+73
-1
lines changed

deployments/frontend.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: frontend
5+
spec:
6+
ports:
7+
- protocol: TCP
8+
port: 80
9+
targetPort: 80
10+
selector:
11+
app: mealplan
12+
tier: frontend
13+
type: LoadBalancer
14+
---
15+
apiVersion: extensions/v1beta1
16+
kind: Deployment
17+
metadata:
18+
name: frontend
19+
spec:
20+
template:
21+
metadata:
22+
labels:
23+
app: mealplan
24+
tier: frontend
25+
spec:
26+
containers:
27+
- image: "coderjourney/mealplan-frontend:1.0.0"
28+
name: nginx
29+
lifecycle:
30+
preStop:
31+
exec:
32+
command: ["/usr/sbin/nginx","-s","quit"]

deployments/postgres.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ spec:
3737
name: postgres
3838
volumeMounts:
3939
- name: postgres-storage
40-
mountPath: /var/lib/postgresql/db-data
40+
mountPath: /var/lib/postgresql/data
4141
volumes:
4242
- name: postgres-storage
4343
persistentVolumeClaim:
@@ -53,3 +53,16 @@ spec:
5353
resources:
5454
requests:
5555
storage: 5Gi
56+
volumeName: postgres-pv
57+
---
58+
apiVersion: v1
59+
kind: PersistentVolume
60+
metadata:
61+
name: postgres-pv
62+
spec:
63+
accessModes:
64+
- ReadWriteOnce
65+
capacity:
66+
storage: 5Gi
67+
hostPath:
68+
path: /data/mealplan-postgres

nginx/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM nginx:1.11.13-alpine
2+
3+
COPY site.conf /etc/nginx/conf.d/default.conf

nginx/site.conf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
upstream mealplan {
2+
server mealplan;
3+
}
4+
5+
server {
6+
listen 80;
7+
8+
# Properly server assets
9+
location ~ ^/(assets)/ {
10+
root /usr/share/nginx/html;
11+
gzip_static on;
12+
expires max;
13+
add_header Cache-Control public;
14+
add_header ETag "";
15+
}
16+
17+
# Proxy request to rails app
18+
location / {
19+
proxy_set_header Host $host;
20+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
21+
proxy_pass_header Set-Cookie;
22+
proxy_pass http://mealplan;
23+
}
24+
}

0 commit comments

Comments
 (0)