Skip to content

Commit 6083215

Browse files
committed
fixed cors and modified docker CI
1 parent e2d9e1e commit 6083215

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

.github/workflows/docker-image.yml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,57 @@ name: Build and Push Docker Image
22

33
on:
44
push:
5+
branches:
6+
- dev
57
tags:
68
- 'v*' # Trigger on tags'
79

810
jobs:
911
build-and-push:
1012
runs-on: ubuntu-latest
1113
steps:
12-
# Step 1: Checkout the repository code
1314
- name: Checkout repository
1415
uses: actions/checkout@v3
1516

16-
# Step 2: Set up QEMU for multi-platform builds
17+
- id: commit
18+
uses: prompt/actions-commit-hash@v3
19+
1720
- name: Set up QEMU
1821
uses: docker/setup-qemu-action@v2
1922
with:
2023
platforms: linux/amd64,linux/arm64
2124

22-
# Step 3: Set up Docker Buildx
2325
- name: Set up Docker Buildx
2426
uses: docker/setup-buildx-action@v2
2527

26-
# Step 4: Log in to Docker Hub
2728
- name: Log in to Docker Hub
2829
uses: docker/login-action@v2
2930
with:
3031
username: ${{ secrets.DOCKERHUB_USERNAME }}
3132
password: ${{ secrets.DOCKERHUB_TOKEN }}
3233

33-
# Step 5: Build and push the Docker image
34+
# Build and push the Docker image (dev)
35+
- name: Build and push Docker image (dev)
36+
if: github.ref == 'refs/heads/dev'
37+
uses: docker/build-push-action@v4
38+
with:
39+
context: .
40+
platforms: linux/amd64,linux/arm64
41+
push: true
42+
build-args: --progress=plain
43+
tags: setavenger/blindbit-oracle:dev-${{ steps.commit.outputs.short }} # Use the short SHA to distinguish dev images
44+
45+
# Build and push the Docker image (tags)
46+
- name: Build and push Docker image
47+
if: startsWith(github.ref, 'refs/tags/')
48+
uses: docker/build-push-action@v4
49+
with:
50+
context: .
51+
platforms: linux/amd64,linux/arm64
52+
push: true
53+
build-args: --progress=plain
54+
tags: setavenger/blindbit-oracle:${{ github.ref_name }}
55+
3456
- name: Build and push Docker image
3557
uses: docker/build-push-action@v4
3658
with:

src/server/run.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@ package server
33
import (
44
"SilentPaymentAppBackend/src/common"
55

6+
"github.com/gin-contrib/cors"
67
"github.com/gin-gonic/gin"
78
)
89

910
func RunServer(api *ApiHandler) {
1011
// todo merge gin logging into common logging
1112
router := gin.Default()
1213

14+
router.Use(cors.New(cors.Config{
15+
AllowOrigins: []string{"*"},
16+
AllowMethods: []string{"GET", "PUT"},
17+
AllowHeaders: []string{"Content-Type", "Authorization"},
18+
AllowCredentials: true,
19+
}))
20+
1321
router.GET("/block-height", api.GetBestBlockHeight)
1422
router.GET("/tweaks/:blockheight", FetchHeaderInvMiddleware, api.GetTweakDataByHeight)
1523
router.GET("/tweak-index/:blockheight", FetchHeaderInvMiddleware, api.GetTweakIndexDataByHeight)

0 commit comments

Comments
 (0)