@@ -10,6 +10,8 @@ Building the package:
1010nix-build -E ' (import ./pkgs.nix {}).callPackage ./default.nix {}'
1111```
1212
13+ ### Nix/NixOS
14+
1315Building the releases:
1416
1517``` sh
@@ -26,6 +28,8 @@ Install into Nix user profile:
2628nix-env -f ./release.nix --install --attr application
2729```
2830
31+ ### Docker
32+
2933Install into Docker:
3034
3135``` sh
@@ -53,12 +57,12 @@ npm run lint
5357npm run lintfix
5458```
5559
56- ### Calling Executables
60+ ### Calling Commands
5761
58- When calling executables in development, use this style:
62+ When calling commands in development, use this style:
5963
60- ```
61- npm run typescript-demo-lib -- p1 p2 p3
64+ ``` sh
65+ npm run polykey -- p1 p2 p3
6266```
6367
6468The ` -- ` is necessary to make ` npm ` understand that the parameters are for your own executable, and not parameters to ` npm ` .
@@ -125,16 +129,6 @@ The folder structure for the executable should look like this.
125129 - linux-x64
126130 - (node files)
127131
128- #### utp-native
129-
130- Including utp-native is simpler, you just need to add it as an asset for pkg.
131- Add the following lines to the package.json.
132- ``` json
133- "pkg" : {
134- "assets" : " node_modules/utp-native/**/*"
135- }
136- ```
137-
138132#### threads.js
139133
140134To make sure that the worker threads work properly you need to include the compiled worker scripts as an asset.
@@ -195,3 +189,65 @@ npm publish --access public
195189git push
196190git push --tags
197191```
192+ ### Packaging Cross-Platform Executables
193+
194+ We use ` pkg ` to package the source code into executables.
195+
196+ This requires a specific version of ` pkg ` and also ` node-gyp-build ` .
197+
198+ Configuration for ` pkg ` is done in:
199+
200+ * ` package.json ` - Pins ` pkg ` and ` node-gyp-build ` , and configures assets and scripts.
201+ * ` utils.nix ` - Pins ` pkg ` for Nix usage
202+ * ` release.nix ` - Build expressions for executables
203+
204+ ## Deployment
205+
206+ Image deployments are done automatically through the CI/CD. However manual scripts are available below for deployment.
207+
208+ ### Deploying to AWS ECR:
209+
210+ #### Using skopeo
211+
212+ ``` sh
213+ tag=' manual'
214+ registry_image=' 015248367786.dkr.ecr.ap-southeast-2.amazonaws.com/polykey'
215+
216+ # Authenticates skopeo
217+ aws ecr get-login-password \
218+ | skopeo login \
219+ --username AWS \
220+ --password-stdin \
221+ " $registry_image "
222+
223+ build=" $( nix-build ./release.nix --attr docker) "
224+ # This will push both the default image tag and the latest tag
225+ ./scripts/deploy-image.sh " $build " " $tag " " $registry_image "
226+ ```
227+
228+ #### Using docker
229+
230+ ``` sh
231+ tag=' manual'
232+ registry_image=' 015248367786.dkr.ecr.ap-southeast-2.amazonaws.com/polykey'
233+
234+ aws ecr get-login-password \
235+ | docker login \
236+ --username AWS \
237+ --password-stdin \
238+ " $registry_image "
239+
240+ build=" $( nix-build ./release.nix --attr docker) "
241+ loaded=" $( docker load --input " $build " ) "
242+ image_name=" $( cut -d' :' -f2 <<< " $loaded" | tr -d ' ' ) "
243+ default_tag=" $( cut -d' :' -f3 <<< " $loaded" ) "
244+
245+ docker tag " ${image_name} :${default_tag} " " ${registry_image} :${default_tag} "
246+ docker tag " ${image_name} :${default_tag} " " ${registry_image} :${tag} "
247+ docker tag " ${image_name} :${default_tag} " " ${registry_image} :latest"
248+
249+ docker push " ${registry_image} :${default_tag} "
250+ docker push " ${registry_image} :${tag} "
251+ docker push " ${registry_image} :latest"
252+ ```
253+
0 commit comments