Skip to content

Commit ac6c95d

Browse files
authored
Merge pull request #136 from Hello-Storage/staging
Staging
2 parents c4aa8a3 + fc42c62 commit ac6c95d

33 files changed

+950
-173
lines changed

.circleci/config.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,17 @@ commands:
3434
command: |
3535
EC2_USERNAME=ubuntu
3636
EC2_PUBLIC_DNS=api-staging.joinhello.app
37-
ssh -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_PUBLIC_DNS "cd workspace/staging && sudo docker compose pull && sudo docker system prune -f && sudo docker compose up -d --build --wait"
37+
# Create an archive of the specified node files
38+
tar -czvf node_files.tar.gz -C ./node .dockerignore .gitignore Dockerfile.dev index.ts nodemon.json package.json tsconfig.json
39+
# Ensure the target directories exist
40+
ssh -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_PUBLIC_DNS "mkdir -p /home/ubuntu/workspace/staging/node"
41+
# Securely copy the updated docker-compose.yml and the node files archive to the server
42+
scp -o StrictHostKeyChecking=no ./docker-compose.yml $EC2_USERNAME@$EC2_PUBLIC_DNS:/home/ubuntu/workspace/staging/docker-compose.yml
43+
scp -o StrictHostKeyChecking=no node_files.tar.gz $EC2_USERNAME@$EC2_PUBLIC_DNS:/home/ubuntu/workspace/staging/node_files.tar.gz
44+
# Extract the node files archive to the correct directory and cleanup
45+
ssh -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_PUBLIC_DNS "cd /home/ubuntu/workspace/staging && tar -xzvf node_files.tar.gz -C node && rm node_files.tar.gz"
46+
# Connect to the server and start the updated setup
47+
ssh -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_PUBLIC_DNS "cd /home/ubuntu/workspace/staging && sudo docker compose pull && sudo docker system prune -f && sudo docker compose up -d --build --wait"
3848
3949
jobs:
4050
build:

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
arweave-wallet.json

.env.example

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ POSTGRES_DB=hello
1414
POSTGRES_USER=postgres
1515
POSTGRES_PASSWORD=postgres
1616
POSTGRES_PORT=5432
17+
PGPASSWORD=postgres
1718

1819
POSTGRES_MOCK_HOST=localhost
1920
POSTGRES_MOCK_DB=mockhello
@@ -29,13 +30,18 @@ RedisPassword=
2930
FILEBASE_ACCESS_KEY=access_key
3031
FILEBASE_SECRET_KEY=access_key
3132
FILEBASE_PINNING_KEY=access_key
33+
AWS_ACCESS_KEY_ID=
34+
AWS_SECRET_ACCESS_KEY=
3235
FILEBASE_ENDPOINT=https://s3.filebase.com
3336
FILEBASE_REGION=us-east-1
3437

38+
3539
WASABI_ACCESS_KEY=access_key
3640
WASABI_SECRET_KEY=access_key
3741
WASABI_ENDPOINT=s3.eu-central-2.wasabisys.com
3842
WASABI_BUCKET=hello-storage
3943
WASABI_REGION=us-east-1
4044

41-
ENCRYPTION_KEY=ThIS_Is_A_32ByTE_LoNG_STrING_123
45+
ENCRYPTION_KEY=ThIS_Is_A_32ByTE_LoNG_STrING_123
46+
47+
NODEJS_SERVER_ENDPOINT=http://nodejs-server:3000

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
*.so
99
*.dylib
1010

11+
arweave-wallet.json
12+
1113
# Test binary, built with `go test -c`
1214
*.test
1315

arweave-wallet.json.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"d": "a_jAwL...",
3+
"dp": "h3n...",
4+
"dq": "DZQ...",
5+
"e": "AQ..",
6+
"kty": "RSA",
7+
"n": "jqf...",
8+
"p": "_AO...",
9+
"q": "kOl...",
10+
"qi": "pfc..."
11+
}

compose.dev.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "3.8"
1+
version: "3.9"
22

33
## FOR TEST AND DEVELOPMENT ONLY, DO NOT USE IN PRODUCTION ##
44

@@ -47,9 +47,27 @@ services:
4747
timeout: 5s
4848
retries: 5
4949

50+
nodejs-server:
51+
container_name: nodejs-server-dev
52+
build:
53+
context: ./node
54+
dockerfile: ./Dockerfile.dev # Adjust if your Dockerfile has a different name or path
55+
restart: always
56+
env_file:
57+
- .env
58+
ports:
59+
- "3000:3000"
60+
volumes:
61+
- ./node:/usr/src/app # This mounts your host node directory to the container's working directory
62+
- ./arweave-wallet.json:/usr/src/app/arweave-wallet.json:ro
63+
- /usr/src/app/node_modules # Persists node_modules folder to avoid being overridden by the bind mount
64+
networks:
65+
- network-backend
66+
5067
networks:
5168
network-backend:
5269
volumes:
5370
postgres-data:
5471
external: true
5572
name: postgres-data
73+

compose.prod.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,23 @@ services:
5353
- '6379:6379'
5454
networks:
5555
- network-backend
56+
nodejs-server:
57+
container_name: nodejs-server-dev
58+
build:
59+
context: ./node
60+
dockerfile: ./Dockerfile.dev # Adjust if your Dockerfile has a different name or path
61+
restart: always
62+
env_file:
63+
- .env
64+
ports:
65+
- "3000:3000"
66+
volumes:
67+
- ./node:/usr/src/app # This mounts your host node directory to the container's working directory
68+
- ./arweave-wallet.json:/usr/src/app/arweave-wallet.json:ro
69+
- /usr/src/app/node_modules # Persists node_modules folder to avoid being overridden by the bind mount
70+
networks:
71+
- network-backend
72+
5673

5774
networks:
5875
network-backend:

docker-compose.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,31 @@ services:
3737
interval: 10s
3838
timeout: 5s
3939
retries: 5
40+
redis:
41+
container_name: redis
42+
image: redis/redis-stack-server:latest
43+
restart: always
44+
ports:
45+
- '6379:6379'
46+
networks:
47+
- network-backend
48+
nodejs-server:
49+
container_name: nodejs-server-dev
50+
build:
51+
context: ./node
52+
dockerfile: ./Dockerfile.dev # Adjust if your Dockerfile has a different name or path
53+
restart: always
54+
env_file:
55+
- .env
56+
ports:
57+
- "3000:3000"
58+
volumes:
59+
- ./node:/usr/src/app # This mounts your host node directory to the container's working directory
60+
- ./arweave-wallet.json:/usr/src/app/arweave-wallet.json:ro
61+
- /usr/src/app/node_modules # Persists node_modules folder to avoid being overridden by the bind mount
62+
networks:
63+
- network-backend
64+
4065

4166
networks:
4267
network-backend:

internal/api/abort.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ func AbortBusy(c *gin.Context) {
7575
Abort(c, http.StatusTooManyRequests, "Busy, please try again later")
7676
}
7777

78-
func ErrorResponse(err error) gin.H {
79-
return gin.H{"error": err.Error()}
78+
func ErrorResponse(err error, code ...string) gin.H {
79+
response := gin.H{"error": err.Error(), "status": "fail"}
80+
81+
if len(code) > 0 {
82+
response["code"] = code
83+
}
84+
85+
return response
8086
}

internal/api/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
var log = event.Log
1616

17+
1718
func Ping(router *gin.RouterGroup) {
1819
router.GET("/", func(c *gin.Context) {
1920
c.JSON(http.StatusOK, "hello backend api endpoints")

0 commit comments

Comments
 (0)