Single step deployment to development and production servers

8

  • 8
  • 0
  • 0.141
  • Reply

  • Open in the desktop app ADD TO PLAYLIST

    smjn

    Published on May 01, 2020
    About :

    Originally intended to publish the code for the updated website, but got carried away and worked on improving the workflow for pushing new builds to servers instead.

    Continuing on the same concepts as I have written about before: Swift & direct development setup and Inspiring workflow. First about being able to code and see the changes in the running project instantly without leaving the editor and the second about working on assets and seeing changes in the running project without leaving the asset application.

    The project template used in those above videos to make games, is the same template used to make the website. Doing the improvements to the workflow for the website means I can transfer the improvements to the games later.

    My old workflow for making a new build was this:

    1. Run the build script and get a new build in folder build/.
    2. Use an extension for VSC called Deploy to execute configurations that would upload the files to a development S3 bucket on AWS.
    3. If the development build performed as intended, using the S3 console to copy the files from development bucket to production bucket.
    4. Go to the CloudFront interface to initiate an invalidation of the files. This makes sure no cached versions of old files are served on the distributed network.
    5. Due to problems getting Deploy to automatically remove files in a way that worked for all situations, I had done two things: 1. Removed hash strings from files in order to overwrite files instead of having duplicate files with different hashes. 2. Using S3 console to manually delete files when needed.

    Steps 1 and 2 would be most of the time. After running the local version for a while, you want to try it in the actual system and upload it to the development server. This was OK. Then the rest of the steps were fine in that they did not occur that often, but it did take a minute or two. Doing it manually also adds the possibility of doing an error!

    The new workflow for deploying a build:

    1. Run the build script and answer at most two questions.

    If for development, answer the question if you want to push all files or only code files. If for production, answer the question if you have remembered to sync git and a final safety question if you are sure want to upload.

    The script takes care of building, adding extra files, editing in differences in paths (if prod and dev have the project in different places, say one in root and the other in a sub-folder), cleaning the S3 bucket, uploading to it and if production invalidating the CloudFront distribution.

    I implemented it like so:

    • Adding a "project_settings" section to the package.json for the project. This contains buckets, cloudfronts, paths and additional files to add to a build.
    • Writing a few short scripts and integrating them into suitable places in the preact.config.js file and using the new project_settings in those scripts.
    • Being clever and using "npm install package X" for everything that would require a bit of time to code. Usually I would avoid using too many packages, as you would want the release to be as small as possible and with as little unknowns as possible. But here the code was only for development tasks, making it not as crucial. Great packages used are: glob, mime, aws-sdk, prompt-confirm, console-progress-bar and git-rev-sync.

    I have a bug I want to fix before uploading to GitHub, but hopefully early next week. While the site might not be awesome as a whole, it has many shorter useful implementations of preact, bulma and S3 uploading.


    Game development using web technologies.

    Spelmakare.se
    Discord
    GitHub

    Try the latest development build of Purple & Eye
    Try the latest development build of Hive Blocks

    Tags :

    development javascript smjnblog gamedev

    Woo! This creator can upvote comments using 3speak's stake today because they are a top performing creator! Leave a quality comment relating to their content and you could receive an upvote worth at least a dollar.

    Their limit for today is $0!
    Comments:
    Time until smjn can give away $0 to their commenters.
    0 Days 0 Hours 0 Minutes 0 Seconds
    Reply:

    To comment on this video please connect a HIVE account to your profile: Connect HIVE Account

    01:22
    15 views 3 years ago $
    00:23
    8 views 2 years ago $
    01:28
    12 views 3 years ago $

    More Videos

    00:57
    6 views 4 years ago $
    03:26
    3 views a year ago $
    00:35
    0 views 2 years ago $
    03:53
    0 views 2 years ago $
    03:24
    6 views 2 years ago $