@@ -10,6 +10,8 @@ Building the package:
10
10
nix-build -E ' (import ./pkgs.nix {}).callPackage ./default.nix {}'
11
11
```
12
12
13
+ ### Nix/NixOS
14
+
13
15
Building the releases:
14
16
15
17
``` sh
@@ -26,6 +28,8 @@ Install into Nix user profile:
26
28
nix-env -f ./release.nix --install --attr application
27
29
```
28
30
31
+ ### Docker
32
+
29
33
Install into Docker:
30
34
31
35
``` sh
@@ -53,12 +57,12 @@ npm run lint
53
57
npm run lintfix
54
58
```
55
59
56
- ### Calling Executables
60
+ ### Calling Commands
57
61
58
- When calling executables in development, use this style:
62
+ When calling commands in development, use this style:
59
63
60
- ```
61
- npm run typescript-demo-lib -- p1 p2 p3
64
+ ``` sh
65
+ npm run polykey -- p1 p2 p3
62
66
```
63
67
64
68
The ` -- ` 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.
125
129
- linux-x64
126
130
- (node files)
127
131
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
-
138
132
#### threads.js
139
133
140
134
To 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
195
189
git push
196
190
git push --tags
197
191
```
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