Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Added AWS guide #17

Merged
merged 3 commits into from
Jul 23, 2021
Merged

Added AWS guide #17

merged 3 commits into from
Jul 23, 2021

Conversation

gibbster
Copy link
Contributor

Created a guide for AWS

sudo yum install ruby binutils gcc git glibc-static gzip libbsd libcurl libedit libicu libsqlite libstdc++-static libuuid libxml2 tar tzdata ruby -y
cd $(mktemp -d)
wget ${SwiftToolchainUrl} -O swift.tar.gz
gunzip < swift.tar.gz | sudo tar -C / -xv --strip-components 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC this wil install the Swift toolchain, which means the host will run the compiler etc which could be a security a risk. we put together https://github.com/swift-server/guides/blob/main/packaging.md to describe different deployment strategies including a tarball, docker or source distribution (which this falls into IIUC). we probably want to update this to reflect these different strategies

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the best choice now would be static stdlib linking, if only one Swift binary is deployed per host.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@tomerd
Copy link
Contributor

tomerd commented Sep 30, 2020

please remove .DS_Store

Copy link
Contributor

@tomerd tomerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks so much for putting this together @gibbster

comments inline

@weissi weissi changed the base branch from master to main October 14, 2020 16:42
@weissi
Copy link
Contributor

weissi commented Oct 14, 2020

[retarged to main branch]

@tomerd
Copy link
Contributor

tomerd commented Feb 17, 2021

hi @gibbster do you want to bring this over the finish line?

@gibbster
Copy link
Contributor Author

hi @gibbster do you want to bring this over the finish line?

Absolutely. I'll pick this up next week.

@hassila
Copy link
Contributor

hassila commented May 6, 2021

@gibbster nice work, was planning to do this and found you already did. Do you plan to finish it up, or do you want help?

@gibbster
Copy link
Contributor Author

gibbster commented May 7, 2021

Thanks @hassila - yes, I must admit I've been dragging my feet on this, so would love some tips. From where I stand I think I need to do two things:

  1. review everything to make sure nothing has changed too much since I authored it. E.g. if there's any best practices that have shifted since I wrote the original version
  2. figure out the current best way to deploy this without installing the toolchain.

If you have any thoughts on either of these topics I would appreciate the help!

@hassila
Copy link
Contributor

hassila commented May 7, 2021

@gibbster I will try to follow the guide and see if it still works and what feedback I can give - with regard to 2 above, I saw the discussion - maybe a good approach would be to separate concerns a bit and provide information on both

  1. how to set up an AWS host for development (which is useful for those of us with unsuitable workstations for linux development) - this would include the toolchain and be the actual build environment used for building the app for deployment
  2. how to set up an AWS host for deployment (using one of the strategies documented - without toolchain, but perhaps simplest with the tar/zip approach (personally I think it would be nice to not use docker for everything...).

For the first use case for development, I would consider adding something along these lines also:


In addition to the AWS console, there is also a command line interface for AWS that can be helpful for day-to-day development with a single instance.

It allows for setting up some simple useful shell commands (this example for the awesome fish shell for an Ubuntu instance) for an individual developer, e.g.:

amazon-dns // find public DNS name for a specific instance ID
amazon-start // start specific instance
amazon-stop // stop specific instance
amazon-login // log into specific instance
> functions amazon-dns
# Defined in /Users/xxx/.config/fish/functions/amazon-dns.fish @ line 1
function amazon-dns
 aws ec2 describe-instances --output text --instance-ids i-0d6f830050ccf632b --query 'Reservations[].Instances[].PublicDnsName' ;
end
> functions amazon-start
# Defined in /Users/xxx/.config/fish/functions/amazon-start.fish @ line 1
function amazon-start
 aws ec2 start-instances --instance i-0d6f830050ccf632b ;
end
> functions amazon-stop
# Defined in /Users/xxx/.config/fish/functions/amazon-stop.fish @ line 1
function amazon-stop
 aws ec2 stop-instances --instance i-0d6f830050ccf632b ;
end
> 
> functions amazon-login
# Defined in /Users/xxx/.config/fish/functions/amazon-login.fish @ line 1
function amazon-login
 ssh -i .ssh/xxx-home.pem ubuntu@(amazon-dns) ;
end

This gives on-demand command line access to the remote host (and one can always put amazon-stop in a cron job if desired...).

@gibbster
Copy link
Contributor Author

@hassila - do you think building the binary with static-stdlib or static-executable would be preferable?

@fabianfett
Copy link
Member

@gibbster -static-stdlib is definitely preferred over -static-executable.

@gibbster
Copy link
Contributor Author

gibbster commented Jun 1, 2021

@hassila I added some updates. Let me know if it addresses the spirit of the static linking request, and if there's any best practices, technical details, screenshots, etc. I should add

@hassila
Copy link
Contributor

hassila commented Jun 2, 2021

Thanks @gibbster, super! I think the most important point is addressed now - the separation between a build host with toolchain and how to build with a static stdlib and deploying on a host without the toolchain. Basically it is the minimalistic approach of the tar archive outlined at (https://github.com/swift-server/guides/blob/main/docs/packaging.md) which points in the right direction.

Some minor structuring nits:

@gibbster
Copy link
Contributor Author

gibbster commented Jun 2, 2021

@hassila - will do. One question: I see that the baseline branch is now main and not master. Should I create a new PR that is based off of main?

@hassila
Copy link
Contributor

hassila commented Jun 2, 2021

@gibbster super. I guess it doesn't matter from which of your forks branch the merge is done, but there was a baseline branch renaming some while ago AFAIU, so perhaps you want to update anyway (I usually fork the repo and do a local feature branch myself when contributing).

@gibbster gibbster mentioned this pull request Jun 2, 2021
@gibbster
Copy link
Contributor Author

gibbster commented Jun 2, 2021

Created a new PR with all the main branch commits merged in: #45

@ktoso ktoso merged commit 5737b74 into swift-server:main Jul 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants