• Stars
    star
    194
  • Rank 200,219 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 5 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Netlify replacement to deploy simple websites with better flexibility, speed and without vendor lock-in

Solid State Deploy

Deploy simple websites with Google Cloud and Cloudflare. It is like Netlify with:

  • Better performance. Cloudflare has more features for fast websites than Netlify CDN. For instance, HTTP/3 and TLS 1.3 0-RTT.
  • Flexibility. You can have crontab jobs and simple scripts (without persistence storage). You will have powerful and well documented Nginx config to define custom headers and redirects.
  • Lack of vendor lock-in. We use industry standards like Docker and Nginx. You can change CI, CDN, or Docker cloud separately.
  • Local tests. You can run a server on your laptop to test redirects and scripts.

You will have built-in HTTPS and deploy by git push.

ssdeploy example

We also have trade-offs. It is not free, but for a simple website, it will cost you cents per month. You need more steps to install it, but after you have the same simple workflow.

Sponsored by Evil Martians

Install

  1. Create an account in Google Cloud.

  2. Go to IAM & Admin → Service Accounts, click Create Service Account and fill form:

    • Service Account Name: Github-actions
    • Service Account Description: Deploy from Github Actions
  3. Add Cloud Run Admin, Storage Admin, Service Account User roles.

  4. Click Create Key, choose JSON → Create, download and keep file for a while.

  5. Open Container Registry and enable the service.

  6. Open Cloud Run and start the service.

  7. Go to your Github page of your project at Settings → Secrets.

  8. Add new secret WEBSITE_URL with URL to your website domain (like example.com).

  9. Add new secret GCLOUD_PROJECT with Google Cloud project name like test-255417. You can find project ID by opening a project switcher at the top of Google Cloud.

  10. Choose application name (like examplecom) and add GCLOUD_APP secret with this name.

  11. Call base64 key-partition-….json (file from step 4) and add GCLOUD_AUTH secret with the base64 content of this file.

  12. Install Solid State Deploy to your project.

    npm i ssdeploy
  13. Create Github Actions workflow by calling:

    npx ssdeploy init
  14. Your project should build HTML files by npm build and put them to dist/.

  15. Push the project’s changes to Github Actions to start deploying. Open Actions tab on Github to check out the process.

  16. Go to Cloud Run at Google Cloud and find your server. Open it by clicking on the name and find the URL like examplecom-hjv54hv.a.run.app. Check that the website is working.

  17. Click on Manage Custom DomainsAdd mapping. Select your app, Verify a new domain, and enter your domain name. Finish domain verification with Webmaster Central.

  18. After verification open Add mapping dialog again, select your app, domain, and leave subdomain blank. You will get A and AAAA records.

  19. Create a new Cloudflare account. Create a site with A and AAAA records from Cloud Run.

  20. Enable HTTP/3 and 0-RTT in Cloudflare Network settings.

  21. Find Zone ID at site overview and create API token with cache cleaner name and Cache Purge/Edit permission.

  22. Use them in CLOUDFLARE_ZONE and CLOUDFLARE_TOKEN secrets at Github.

  23. Go to Google Cloud Run, Manage Custom DomainsAdd mapping to add www subdomain and add CNAME record to Cloudflare DNS settings.

We recommend checking the final result for blocking in Russia and recreate Cloudflare account to change IP addressed.

Few extra steps will improve security:

  1. Go to Cloudflare SSL/TLS settings and enable Full encryption mode.

  2. Add CAA records to Cloudflare DNS settings:

    CAA @   0 "only allow specific hostname" digicert.com
    CAA @   0 "only allow specific hostname" letsencrypt.org
    CAA www 0 "only allow specific hostname" digicert.com
    CAA www 0 "only allow specific hostname" letsencrypt.org
  3. Enable DNSSEC in DNS settings.

  4. Enable HTST by creating nginx.conf in the root of your project with:

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
    add_header X-Content-Type-Options "nosniff";

Deploy

Just push commits to master:

git push origin master

You can switch deploy branch at .Github/workflows/deploy.yml.

Run Server Locally

To test the Docker image locally run:

npm build
npx ssdeploy run

Deploy Server Locally

You can deploy a server from the laptop. It can be useful to debug.

You need to install Google Cloud SDK and call:

npx ssdeploy deploy

Custom Nginx config

In custom Nginx config, you can define headers and redirects. Create nginx.conf in your project root.

if ($host ~ ^www\.(?<domain>.+)$) {
  return 301 https://$domain$request_uri;
}

location ~* "(\.css|\.png|\.svg|\.woff2)$" {
  add_header Cache-Control "public, max-age=31536000, immutable";
}

It will be included inside the server context.

Custom Docker config

Custom Dockerfile should be placed at your project root. It can be used to define crontab jobs:

FROM nginx:alpine
RUN rm -R /etc/nginx/conf.d
COPY ./dist/ /var/www/
COPY ./node_modules/ssdeploy/configs/nginx.conf /etc/nginx/nginx.template
COPY ./nginx.conf /etc/nginx/server.conf
RUN echo "#\!/bin/sh\necho 1" > /etc/periodic/hourly/example
RUN chmod a+x /etc/periodic/hourly/example
CMD crond && envsubst \$PORT < /etc/nginx/nginx.template > /etc/nginx/nginx.conf && nginx

More Repositories

1

nanoid

A tiny (124 bytes), secure, URL-friendly, unique string ID generator for JavaScript
JavaScript
24,064
star
2

easings.net

Easing Functions Cheat Sheet
CSS
7,908
star
3

size-limit

Calculate the real cost to run your JS app or lib to keep good performance. Show error in pull request if the cost exceeds the limit.
JavaScript
6,487
star
4

visibilityjs

Wrapper for the Page Visibility API
JavaScript
1,825
star
5

nanoevents

Simple and tiny (107 bytes) event emitter library for JavaScript
TypeScript
1,442
star
6

autoprefixer-rails

Autoprefixer for Ruby and Ruby on Rails
Ruby
1,213
star
7

nanocolors

Use picocolors instead. It is 3 times smaller and 50% faster.
JavaScript
868
star
8

audio-recorder-polyfill

MediaRecorder polyfill to record audio in Edge and Safari
JavaScript
580
star
9

keyux

JS library to improve keyboard UI of web apps
TypeScript
380
star
10

webp-in-css

PostCSS plugin and tiny JS script (131 bytes) to use WebP in CSS background
JavaScript
346
star
11

offscreen-canvas

Polyfill for OffscreenCanvas to move Three.js/WebGL/2D canvas to Web Worker
JavaScript
332
star
12

convert-layout

JS library to convert text from one keyboard layout to other
JavaScript
251
star
13

environment

My home config, scripts and installation process
Shell
193
star
14

nanodelay

A tiny (37 bytes) Promise wrapper around setTimeout
JavaScript
189
star
15

dual-publish

Publish JS project as dual ES modules and CommonJS package to npm
JavaScript
186
star
16

nanospy

Spy and mock methods in tests with great TypeScript support
TypeScript
138
star
17

check-dts

Unit tests for TypeScript definitions in your JS open source library
JavaScript
138
star
18

autoprefixer-core

autoprefixer-core was depreacted, use autoprefixer
JavaScript
136
star
19

transition-events

jQuery plugin to set listeners to CSS Transition animation end or specific part
JavaScript
133
star
20

evil-blocks

Tiny framework for web pages to split your app to separated blocks
JavaScript
127
star
21

rails-sass-images

Sass functions and mixins to inline images and get images size
Ruby
114
star
22

compass.js

Compass.js allow you to get compass heading in JavaScript by PhoneGap, iOS API or GPS hack.
CoffeeScript
112
star
23

evil-front

Helpers for frontend from Evil Martians
Ruby
101
star
24

rake-completion

Bash completion support for Rake
Shell
63
star
25

yaspeller-ci

Fast spelling check for Travis CI
JavaScript
61
star
26

jquery-cdn

Best way to use latest jQuery in Ruby app
Ruby
59
star
27

sitnik.ru

My homepage content and scripts
JavaScript
57
star
28

pages.js

CoffeeScript
44
star
29

fotoramajs

Fotorama for Ruby on Rails
Ruby
44
star
30

about-postcss

Keynotes about PostCSS
Ruby
29
star
31

autohide-battery

GNOME Shell extension to hide battery icon in top panel, if battery is fully charged and AC is connected.
JavaScript
28
star
32

darian

Darian Mars calendar converter
Ruby
25
star
33

better-node-test

The CLI shortcut for node --test runner with TypeScript
JavaScript
25
star
34

plain_record

Data persistence with human readable and editable storage.
Ruby
24
star
35

evolu-lang

Programming language to automatically generate programs by evolution (genetic programming).
JavaScript
22
star
36

martian-logux-demo

TypeScript
17
star
37

hide-keyboard-layout

GNOME Shell extension to hide keyboard layout indicator in status bar
JavaScript
17
star
38

twitter2vk

Script to automatically repost statuses from Twitter to VK (В Контакте)
Ruby
16
star
39

asdf-cache-action

A Github Action to install runtimes by asdf CLI with a cache
15
star
40

ci-job-number

Return CI job number to run huge tests only on first job
JavaScript
15
star
41

print-snapshots

Print Jest snapshots to check CLI output of your tool
JavaScript
15
star
42

load-resources

Load all JS/CSS files from site website
JavaScript
15
star
43

susedko

Fedora CoreOS ignition config for my home server
JavaScript
14
star
44

file-container

Store different languages in one source file
JavaScript
14
star
45

postcss-isolation

Fix global CSS with PostCSS
14
star
46

autoprefixer-cli

CLI for Autoprefixer
JavaScript
14
star
47

d2na

D²NA language for genetic programming
Ruby
11
star
48

showbox

Keynote generator
JavaScript
11
star
49

boilerplates

Boilerplate for my open source projects
JavaScript
9
star
50

postcss-way

Keynotes about PostCSS way
9
star
51

gulp-bench-summary

Display gulp-bench results in nice table view
JavaScript
8
star
52

universal-layout

Универсальная раскладка Ситника
8
star
53

anim2012

Доклад «Анимации по-новому — лень, гордыня и нетерпимость»
CSS
8
star
54

nanopurify

A tiny (from 337 bytes) HTML sanitizer
JavaScript
7
star
55

ai

6
star
56

rit3d

Доклад «Веб, теперь в 3D: Практика»
CSS
6
star
57

dis.spbstu.ru

Department homepage
Ruby
5
star
58

jstransformer-lowlight

Lowlight support for JSTransformers
JavaScript
5
star
59

jest-ci

CLI for Jest test framework, but coverage only on first CI job
JavaScript
5
star
60

evolu-steam

Evolu Steam – evolutionary computation for JavaScript
JavaScript
5
star
61

insomnis

Текст блогокниги «Инсомнис»
4
star
62

plague

Blog/book Plague engine
Ruby
4
star
63

wsd2013

Презентация «Автопрефиксер: мир без CSS-префиксов»
Ruby
4
star
64

showbox-bright

Shower Bright theme for Showbox
JavaScript
3
star
65

ruby2jar

Ruby2Jar builds JAR from a Ruby script
Ruby
3
star
66

showbox-ai

Sitnik’s theme for ShowBox
CSS
3
star
67

showbox-shower

Shower for ShowBox
JavaScript
2
star
68

on_the_islands

Ruby
2
star