Search…
Define a Static Javascript Service
How to define a new static javascript service or convert an existing docker service to use a static javascript build deployed to a CDN
Creating a static javascript service in Release requires the following parameters:
  • static: 'true' for static build 'false' to switch back to a docker build
  • _build_base:_path to the javascript project within your repository
  • build_command: your javascript build command
  • build_output_directory: the the directory that the build command outputs the build to
1
services:
2
- name: frontend
3
static: true
4
build_command: GENERATE_SOURCEMAP=false yarn build
5
build_base: frontend
6
build_output_directory: build/
Copied!
Static Build example

Adding Basic Authentication to Static Sites

Occasionally you might want to protect your static site from curious eyes if you want the benefits of a static CDN site without the anonymous lookers on the Internet. Release has a simple way to add Basic Authentication to your static content via our proprietary Edge Routing System.
Static Site Basic Authentication does not allow for multiple users with their own passwords. It is only suitable for a single shared user and password scheme. It is not suitable for production environments.
Basic Authentication does not use encryption to secure usernames and/or passwords. It is not suitable for applications running in production.
If you would like to add Basic Authentication to your site, simply setup a static application as shown in the previous section. Then, find the hostnames entry for your static application as shown in this example:
1
hostnames:
2
- api-${env_id}-${domain}
3
- web-client-${env_id}-${domain}
Copied!
Then, replace the web-client-... line with the following example:
1
hostnames:
2
- api-${env_id}-${domain}
3
routes:
4
- name: web-client
5
hostname: web-client-${env_id}-${domain}
6
auth:
7
username: admin
8
password: letmein
9
rules:
10
- service: web-client
11
path: "/"
Copied!

Converting an Existing Docker Service to Static Javascript

If you already have an app that was created with a javascript frontend as a docker service. Or you want to have ephemeral environments running javascript in docker containers for development purposes and static builds in staging to resemble production to verify the static build before you go to production. Release makes this easy by allowing you to define a service with both static javascript and docker service parameters.
You can easily convert any single page javascript docker service to a static javascript build. Here is a docker based javascript frontend that was generated from a docker-compose by Release:
1
services:
2
- name: frontend
3
image: acme-co/awesome-project/frontend
4
ports:
5
- type: node_port
6
target_port: '3000'
7
port: '3000'
8
has_repo: true
9
memory:
10
limits: 4Gi
11
requests: 100Mi
Copied!
Docker based javascript frontend
To update this to use static builds just add the same parameters from the previous section to the service. You can use static parameter to switch the service between static javascript build or running in a docker container.
1
services:
2
- name: frontend
3
image: acme-co/awesome-project/frontend
4
ports:
5
- type: node_port
6
target_port: '3000'
7
port: '3000'
8
has_repo: true
9
memory:
10
limits: 4Gi
11
requests: 100Mi
12
static: true
13
build_command: yarn build
14
build_base: frontend
15
build_output_directory: build/
Copied!
Docker and static javascript build combo definition