You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: adminforth/documentation/blog/2025-02-19-compose-ec2-deployment-ci-registry/index.md
+41-19Lines changed: 41 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,6 @@ Previously we had a blog post about [deploying AdminForth to EC2 with Terraform
35
35
36
36
So obviously to solve this problem we need to move the build process to CI, however it introduces new chellenges and we will solve them in this post.
37
37
38
-
39
38
Quick difference between approaches from previous post and current post:
40
39
41
40
| Feature | Without Registry | With Registry |
@@ -44,8 +43,11 @@ Quick difference between approaches from previous post and current post:
44
43
| How Docker build layers are cached | Cache is stored on EC2 | GitHub actions has no own Docker cache out of the box, so it should be stored in dedicated place (we use self-hosted registry on the EC2 as it is free) |
45
44
| Advantages | Simpler setup with less code (we don't need code to run and secure registry, and don't need extra cache setup as is naturally persisted on EC2). | Build is done on CI, so EC2 server is not overloaded. For most cases CI builds are faster than on EC2. Plus time is saved because we don't need to rsync source code to EC2 |
46
45
| Disadvantages | Build on EC2 requires additional server RAM / overloads CPU | More terraform code is needed. Registry cache might require small extra space on EC2. Complexities to make it run from both local machine and CI |
47
-
| Initial build time *from local machine up to working state | 2m 48.412s ||
48
-
| Rebuild time *from local machine, no docker cache changed `index.ts`| 0m 34.520s ||
#### 2. You need to deliver same secrets from local machine as from CI vault
961
971
962
-
Create file `deploy/.env.secrets.live` with next content:
972
+
Create file `deploy/.env.secrets.prod` with next content:
963
973
964
974
```sh
965
975
ADMINFORTH_SECRET=<your secret>
@@ -969,7 +979,8 @@ Please note that if you are running builds both from GA and local, the `ADMINFOR
969
979
970
980
#### 2. You need to add app.server.local to your hosts file (Windows/WSL only)
971
981
972
-
> This step is not needed on Linux / Mac because
982
+
> This step is not needed on Linux / Mac because teraform provisioner will autiomatically add it to `/etc/hosts` file.
983
+
> However in WSL we can't modify Windows native hosts file, so we need to do it manually.
973
984
974
985
In power shell run
975
986
@@ -981,4 +992,15 @@ Check your public IP in Terraform output and add
981
992
982
993
```
983
994
<yourpublicip> appserver.local
984
-
```
995
+
```
996
+
997
+
> Bad news is that instance public IP will be known only after first run, so some steps would fail because there will be no hosts mapping. However since EC2 provisioning takes some time it is even possible to copy IP from terminal and inser it to hosts file from first run 🤪
998
+
999
+
1000
+
### 3. Using local build from multiple projects
1001
+
1002
+
The easiest way would be probably to rename `appserver.local` to unique name for each project.
1003
+
1004
+
Then you can put all certificate mappings to a `buildkitd.toml` and move it along with `create-builder.sh` script to a common folder, e.g. home
0 commit comments