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 a static build, false to switch back to a Docker build.
  • build_base: the path to the JavaScript project in your repository.
  • build_command: your JavaScript build command.
  • build_output_directory: the directory the build command outputs the build to.
Here's an example static build:
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!

Adding basic authentication to static sites

If you want the benefits of a static CDN site but don’t want your site to be public, 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, set up 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!
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

Release allows you to define a service with both static JavaScript and Docker service parameters. You can also 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!
You can update this to use static builds by adding the same parameters for defining a static JavaScript service as outlined above. Use the static parameter to switch the service between a static JavaScript build and 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!