storj / edge

Storj edge services (including multi-tenant, S3-compatible server to interact with the Storj network)
GNU Affero General Public License v3.0
48 stars 18 forks source link

Bundle static assets #425

Closed amwolff closed 2 months ago

amwolff commented 2 months ago

Goal

Link Sharing Service static assets need to be bundled into the binary to streamline deployment and ensure their availability within the application.

What needs to be done?

AC

pwilloughby commented 2 months ago

Salt can't checkout the assets from github? I assume it's going to be pulling down the binaries from there so it seems like it should be able to handle a few more files pretty easily.

amwolff commented 2 months ago

yeah, I suppose it's optional. I'll lower the priority of this.

halkyon commented 2 months ago

Salt can't checkout the assets from github? I assume it's going to be pulling down the binaries from there so it seems like it should be able to handle a few more files pretty easily.

I’ve tried this on my own setup with systemd, it feels real hacky and not as elegant as the binary having all the dependencies included. I also had some reliability issues trying to get the revision archive on GitHub for a specific release, and then make sure the right one is used if it swaps out an existing one. IMO better to bundle, and a build artifact should have everything it needs included and not require additional files for it to operate correctly.

Here was the code I had problems with. Maybe there's other ways to do it, of course.

{% set release = salt['pillar.get']('linksharing:release', '') %}
{% set revision = release.split('-')[0] %}

# todo: this isn't so nice. we should look at bundling the static files into the binary.
# todo: file.copy didn't seem to work copying a directory from the git checkout. For now, this creates a new checkout
# and updates the symlink when the source changes. Old directories need to be cleaned up.
{%- if revision != '' %}
linksharing-repo:
  git.detached:
    - name: https://github.com/storj/edge.git
    - rev: {{ revision }}
    - target: {{ data_dir }}/edge-{{ revision }}.git
    - user: {{ user }}
  file.symlink:
    - name: {{ data_dir }}/web
    - target: {{ data_dir}}/edge-{{ revision }}.git/pkg/linksharing/web
    - force: True
    - user: {{ user }}
    - group: {{ user }}
    - mode: '0700'
    - require:
      - file: linksharing-data_dir
      - git: linksharing-repo
{%- endif %}
pwilloughby commented 2 months ago

zip up the assets along with the release binary? The bundling would be nice if it's not more effort, having software delivered as multiple files feels pretty standard to me.

storj-gerrit[bot] commented 2 months ago

Change pkg/linksharing/sharing: embed web assets mentions this issue.

jewharton commented 2 months ago

I've just pushed a Gerrit change that embeds the web assets in the linksharing binary. Any assets in these folders will be included once a build is performed:

halkyon commented 2 months ago

@jewharton This change looks great. Well done!