Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static buckets #39

Open
davidthor opened this issue Jun 13, 2023 · 1 comment · May be fixed by #194
Open

Static buckets #39

davidthor opened this issue Jun 13, 2023 · 1 comment · May be fixed by #194
Assignees
Labels
components Issues related to creating components enhancement New feature or request

Comments

@davidthor
Copy link
Member

davidthor commented Jun 13, 2023

Component schema

version: v2

builds:
  website:
    context: ./frontend

buckets:
  bucket1:
    directory: ./static
    description: Static bucket to be filled with the contents of my local `./static` folder
  website:
    description: Bucket to be filled with the `dist` folder output by the build step below
    deploy:
      image: ${{ builds.website.image }}
      command: npm run build
      publish: ./dist
      environment:
        # Static websites can only connect to ingress rules
        API_ADDR: ${{ ingresses.api.url }}
        AUTH_ADDR: ${{ dependencies.auth.ingresses.main.url }}

# Static buckets can also define ingress rules for how traffic should be routed to them
ingresses:
  website:
    bucket: website
@davidthor davidthor added this to the v0.2 - Lifecycle hooks milestone Jun 13, 2023
@davidthor davidthor self-assigned this Dec 1, 2023
@davidthor
Copy link
Member Author

Implementation of this is proving a bit more difficult than I thought, but I'm starting to get a handle on it. For my own sake, I'm going to jot down the different flows that matter and what I expect the graph steps to be for each.

Deploy from source

This would happen if you try to deploy a component from source that requires a build step. This is a common flow for static websites:

$ arcctl deploy ./architect.yml -e test

Below is an example of an architect.yml file that we'll be deploying:

version: v2

# This docker image basically just 
#   1. installs node/npm, 
#   2. copies in the entire source code, and 
#   3. runs npm install
builds:
  website:
    context: ./

# We'll run a deploy hook right before we deploy the component (not when we build it)
# so that environment variables get replaced correctly (e.g. just-in-time builds)
buckets:
  website:
    deploy:
      image: ${{ builds.website.image }}
      command: npm run build
      publish: ./build
      environment:
        SELF_ADDR: ${{ ingresses.website.url }}

ingresses:
  website:
    bucket: website

When deployed from source, this would yield the following steps:

  1. Turn builds into docker images
  2. Create bucket
  3. Create ingress
  4. Create volume to store bucket contents in
  5. Run task and put publish contents into the volume
  6. Run task to migrate volume contents into bucket
  7. Clean up volume

Deploy from built component

This is basically the same as the above, but without the build step since the docker image is already built.

$ arcctl deploy architectio/component:latest -e test

The component schema would look like this:

version: v2

buckets:
  website:
    deploy:
      image: architectio/component:website-latest
      command: npm run build
      publish: ./build
      environment:
        SELF_ADDR: ${{ ingresses.website.url }}

ingresses:
  website:
    bucket: website

The steps are nearly identical, but have one less step at the beginning:

  1. Create bucket
  2. Create ingress
  3. Create volume to store bucket contents in
  4. Run task and put publish contents into the volume
  5. Run task to migrate volume contents into bucket
  6. Clean up volume

Deploying from source with static bucket contents

This is a case where we want to use our bucket as basically a CDN:

version: v2

buckets:
  images:
    directory: ./images

ingresses:
  images:
    bucket: images

If we deploy the above, it would do the following. Step 2.b.ii isn't immediately intuitive, but the reason we have to use the same volume flows as the previous steps is because we have no guarantees that each step will run on the same host machine (e.g. CI systems with multiple workers or ephemeral hosts). The volume acts as a persistent store between steps, and also allows step 2.b.iii to be the same across all use-cases.

  1. Create bucket
  2. -- The following can be done in parallel --
    a. Create ingress
    b. Push contents to bucket
    1. Create volume to put contents int
    2. Package directory contents into container task that will fill the volume
    3. Run task to migrate volume contents into bucket
    4. Clean up volume

@davidthor davidthor added enhancement New feature or request components Issues related to creating components labels Dec 1, 2023
This was referenced Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
components Issues related to creating components enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant