Skip to content

Commit fbbddc6

Browse files
authored
chore: switch from static to nginx buildpack deployment strat (#372)
1 parent 08d58a7 commit fbbddc6

File tree

8 files changed

+183
-15
lines changed

8 files changed

+183
-15
lines changed

.github/workflows/deploy.yml

+2-10
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,11 @@ jobs:
2020
env:
2121
API_KEY: ${{ secrets.IBM_CLOUD_KEY }}
2222
run: ibmcloud login -a https://api.ng.bluemix.net --apikey $API_KEY -o IBMDesignOrg -s idl
23-
- name: Install plugins for US endpoint
24-
run: |
25-
ibmcloud cf add-plugin-repo CF-Community https://plugins.cloudfoundry.org
26-
ibmcloud cf install-plugin blue-green-deploy -f -r CF-Community
2723
- name: Deploy to US
28-
run: ibmcloud cf blue-green-deploy design-language-website-carbon -f manifest.production.yml --delete-old-apps
24+
run: ibmcloud cf v3-zdt-push design-language-website-carbon -b https://github.com/cloudfoundry/nginx-buildpack.git
2925
- name: Login to to EU
3026
env:
3127
API_KEY: ${{ secrets.IBM_CLOUD_KEY }}
3228
run: ibmcloud login -a https://api.eu-de.bluemix.net --apikey $API_KEY -o IBMDesignOrg -s idl
33-
- name: Install plugins for EU endpoint
34-
run: |
35-
ibmcloud cf add-plugin-repo CF-Community https://plugins.cloudfoundry.org
36-
ibmcloud cf install-plugin blue-green-deploy -f -r CF-Community
3729
- name: Deploy to EU
38-
run: ibmcloud cf blue-green-deploy design-language-website-carbon -f manifest.production.yml --delete-old-apps
30+
run: ibmcloud cf v3-zdt-push design-language-website-carbon -b https://github.com/cloudfoundry/nginx-buildpack.git

buildpack.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
nginx:
3+
version: mainline

conf.d/cache.conf

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Gatsby caching recommendations: https://www.gatsbyjs.org/docs/caching/
2+
3+
## No-cache
4+
location ~* \.html$ {
5+
add_header Cache-Control "public, max-age=0, must-revalidate";
6+
expires off;
7+
}
8+
9+
location /page-data {
10+
add_header Cache-Control "public, max-age=0, must-revalidate";
11+
expires off;
12+
}
13+
14+
location /sw.js {
15+
add_header Cache-Control "public, max-age=0, must-revalidate";
16+
expires off;
17+
}
18+
19+
## Cache
20+
location /static {
21+
add_header Cache-Control "public, max-age=31536000, immutable";
22+
expires 1y;
23+
}
24+
25+
location ~* \.(js|css)$ {
26+
add_header Cache-Control "public, max-age=31536000, immutable";
27+
expires 1y;
28+
}

conf.d/rewrite.conf

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
## Permanent rewrites

manifest.production.yml

-5
This file was deleted.

mime.types

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
types {
2+
text/html html htm shtml;
3+
text/css css;
4+
text/xml xml;
5+
image/gif gif;
6+
image/jpeg jpeg jpg;
7+
application/x-javascript js;
8+
application/atom+xml atom;
9+
application/rss+xml rss;
10+
font/ttf ttf;
11+
font/woff woff;
12+
font/woff2 woff2;
13+
text/mathml mml;
14+
text/plain txt;
15+
text/vnd.sun.j2me.app-descriptor jad;
16+
text/vnd.wap.wml wml;
17+
text/x-component htc;
18+
text/cache-manifest manifest;
19+
image/png png;
20+
image/tiff tif tiff;
21+
image/vnd.wap.wbmp wbmp;
22+
image/x-icon ico;
23+
image/x-jng jng;
24+
image/x-ms-bmp bmp;
25+
image/svg+xml svg svgz;
26+
image/webp webp;
27+
application/java-archive jar war ear;
28+
application/mac-binhex40 hqx;
29+
application/msword doc;
30+
application/pdf pdf;
31+
application/postscript ps eps ai;
32+
application/rtf rtf;
33+
application/vnd.ms-excel xls;
34+
application/vnd.ms-powerpoint ppt;
35+
application/vnd.wap.wmlc wmlc;
36+
application/vnd.google-earth.kml+xml kml;
37+
application/vnd.google-earth.kmz kmz;
38+
application/x-7z-compressed 7z;
39+
application/x-cocoa cco;
40+
application/x-java-archive-diff jardiff;
41+
application/x-java-jnlp-file jnlp;
42+
application/x-makeself run;
43+
application/x-perl pl pm;
44+
application/x-pilot prc pdb;
45+
application/x-rar-compressed rar;
46+
application/x-redhat-package-manager rpm;
47+
application/x-sea sea;
48+
application/x-shockwave-flash swf;
49+
application/x-stuffit sit;
50+
application/x-tcl tcl tk;
51+
application/x-x509-ca-cert der pem crt;
52+
application/x-xpinstall xpi;
53+
application/xhtml+xml xhtml;
54+
application/zip zip;
55+
application/octet-stream bin exe dll;
56+
application/octet-stream deb;
57+
application/octet-stream dmg;
58+
application/octet-stream eot;
59+
application/octet-stream iso img;
60+
application/octet-stream msi msp msm;
61+
application/json json;
62+
audio/midi mid midi kar;
63+
audio/mpeg mp3;
64+
audio/ogg ogg;
65+
audio/x-m4a m4a;
66+
audio/x-realaudio ra;
67+
video/3gpp 3gpp 3gp;
68+
video/mp4 mp4;
69+
video/mpeg mpeg mpg;
70+
video/quicktime mov;
71+
video/webm webm;
72+
video/x-flv flv;
73+
video/x-m4v m4v;
74+
video/x-mng mng;
75+
video/x-ms-asf asx asf;
76+
video/x-ms-wmv wmv;
77+
video/x-msvideo avi;
78+
}

nginx.conf

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
worker_processes 1;
2+
daemon off;
3+
4+
error_log stderr;
5+
events { worker_connections 1024; }
6+
7+
http {
8+
charset utf-8;
9+
default_type application/octet-stream;
10+
include mime.types;
11+
12+
keepalive_timeout 15;
13+
autoindex off;
14+
server_tokens off;
15+
port_in_redirect off;
16+
sendfile on;
17+
tcp_nopush on;
18+
19+
gzip on;
20+
gzip_comp_level 5;
21+
gzip_min_length 256;
22+
gzip_proxied any;
23+
gzip_vary on;
24+
gzip_types
25+
application/javascript
26+
application/json
27+
application/x-javascript
28+
application/rss+xml
29+
text/javascript
30+
text/css
31+
text/plain
32+
image/svg+xml;
33+
34+
35+
log_format cloudfoundry 'NginxLog "$request" $status $body_bytes_sent';
36+
access_log /dev/stdout cloudfoundry;
37+
38+
server {
39+
listen {{port}};
40+
server_name localhost;
41+
root public;
42+
43+
## Force https
44+
set $updated_host $host;
45+
if ($http_x_forwarded_host != "") {
46+
set $updated_host $http_x_forwarded_host;
47+
}
48+
if ($http_x_forwarded_proto != "https") {
49+
return 301 https://$updated_host$request_uri;
50+
}
51+
52+
index index.html;
53+
autoindex off;
54+
55+
error_page 404 /404;
56+
57+
include conf.d/*.conf;
58+
}
59+
}

src/pages/404.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
import { FourOhFour } from 'gatsby-theme-carbon';
3+
4+
const links = [
5+
{ href: '/philosophy/pov', text: 'Philosophy' },
6+
{ href: '/gallery', text: 'Gallery' },
7+
{ href: '/updates/whats-new', text: 'What’s new' },
8+
];
9+
10+
const Custom404 = () => <FourOhFour links={links} />;
11+
12+
export default Custom404;

0 commit comments

Comments
 (0)