Skip to content

Simple gallery website for promoting an artist

License

Notifications You must be signed in to change notification settings

sadstag/gallery

Repository files navigation

Gallery

Simple gallery website for promoting an artist.

It takes google spreadsheets describing artworks and deploys a 100% front application to display them.

Setting things up

These are the step to follow in order to have your site deployed:

things to setup once

adding a site

Choose an site_id for your site, something short and meaningful (with letters and digits).

You should have your google spreadsheet artworks catalog ready, with at least a few artworks in it to start with. Report to this doc for informations about gallery spreadsheet datasources and how to create one.

configuration file

Create a folder named like your site_id in the folder sites.

Create a file sites/[site_id]/input/config.json, you can copysites/demo/input/config.json to create your own and customize.

Report to this doc for detailed information.

speadsheet ingestion

it's time to absorb the content of the source spreadsheet, execute :

$ SITE=[site_id] ./gallery.sh ingest

This should produce a file : sites/[site_id]/public/artwork.json

give artworks images

Put the images corresponding to your artworks in a new folder sites/[site_id]/input/images

Each file should be named [artwork_id].[ext] where artwork_id is the id of artwork in the source spreadsheet and ext is either 'jpg' either 'webp'.

For better results images shoéuld be in lossless webp format and width should be greater than 2400 pixels.

resize artworks images

Ask the gallery CLI tool to do the resizing of the artworks images :

$ SITE=[site_id] ./gallery.sh resize

this should produce all variants of resized images in sites/[site_id]/public/artworks/images.

building the front app

It's now to build the web app.

$ SITE=[site_id] ./gallery.sh build_front

now you should be able to preview using

$ SITE=[site_id] ./gallery.sh preview_front

deploying the app

have terraform config setup/updated

terraform does the provisionning of the needed resource on GCP :

  • buckets (one per site), public access
  • static IP to be attached to the server virtual machine
  • artifact repository for storing docker images of the server

It can be done only when the first site is configured.

$ ./gallery.sh terraform_config # this create the terraform configuration file : terraform/terraform.tfvars.json
$ ./gallery.sh terraform init # terrform will load GCP related terraform providers : should be done once only
$ ./gallery.sh terraform apply # this does the provisionning

directing domain names

once the infrastructure is created you'll need to map your domain names to the reserved static IP.

find the static ip using

$ ./gallery.sh terraform output
# outputs:
# gallery_server_ip = "xxx.xxx.xxx.xxx"

Go to your domain name registrar and create/update the A records so that it points to that IP.

NAME                  TYPE     DATA
@                     A        <you static ip>

folder sites/[site_id]/ structure

TODO maybe

CLI commands

Here are all available CLI commands and what they do. Details in the next sections

command purpose
Common
ingest read spreadsheet of a site to generate the artworks.json database file
assets reduce and upload all assets of site in a dedicated bucket

common CLI command details

data ingestion

This the operation reading the source speadsheet of a site and generating the artworks.json file from it.

$ SITE=[site_id] ./gallery.sh ingest

image resizing

creates resized versions of source artworks

$ SITE=[site_id] ./gallery.sh resize

bucket sync

Sent all resized images to GCP buckets

$ SITE=[site_id] ./gallery.sh sync_bucket

building server docker image

Using SWS (+link)

$ ./gallery.sh build_server

then

$ ./gallery.sh deploy_server

about dev image

option -d for building dev image suitable for local testing.

Specificities:

  • uses port 8080 on host to relay container port 80
  • virtual host configuration refers to port 8080

In order to test the image locally you would have to

  • first ingest the datasheet, the build the front
  • modifiy /etc/hosts to have your domain names point to 127.0.0.1
    • don't forget to remove these lines when testing prod
  • build image
$ ./gallery.sh build_server_dev
  • run image
$ cd sites
$ docker build . -t gallery && docker run --rm --name gallery_instance -p 8080:80 gallery
  • browse http://<domain_name>:8080

Problems and solutions

ZONE_RESOURCE_POOL_EXHAUSTED whe deploying server

$ SITE=X ./gallery.sh deploy_server

...
ERROR: (gcloud.compute.instances.create-with-container) Could not fetch resource:
---
code: ZONE_RESOURCE_POOL_EXHAUSTED

There is no available VM with requested specifications in the requested zone? Try another zone by chabnging server_zone in global configuration

About

Simple gallery website for promoting an artist

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published