Compare commits
19 Commits
2996aefa8f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7c0596c03 | ||
|
|
f4714e2e2a | ||
|
|
eb8cb1608e | ||
|
|
ce3dcd2aec | ||
|
|
3cde6f7810 | ||
|
|
cdd7730141 | ||
|
|
d109e04e63 | ||
|
|
1d194dacdc | ||
|
|
bcdf3cc9b1 | ||
|
|
265fddaa75 | ||
|
|
18dde9b423 | ||
|
|
72f27ede55 | ||
|
|
8afb048664 | ||
|
|
9794c1b212 | ||
|
|
e826cca9fc | ||
|
|
1047225b76 | ||
|
|
d9b92e3e6c | ||
|
|
666449e5c5 | ||
|
|
4065fa13ec |
56
.gitea/workflows/ci.yaml
Normal file
56
.gitea/workflows/ci.yaml
Normal file
@@ -0,0 +1,56 @@
|
||||
name: Build and Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
REGISTRY: localhost:9999
|
||||
IMAGE_NAME: ${{ secrets.PROJECT_NAME }}
|
||||
|
||||
jobs:
|
||||
cleaning:
|
||||
runs-on: host
|
||||
container: null
|
||||
steps:
|
||||
- name: Cleanup
|
||||
run: |
|
||||
docker stop $IMAGE_NAME || true
|
||||
docker rm $IMAGE_NAME || true
|
||||
docker container prune -f
|
||||
docker image prune -af
|
||||
|
||||
build_image:
|
||||
runs-on: host
|
||||
needs: cleaning
|
||||
steps:
|
||||
- name: Clone repo
|
||||
run: |
|
||||
git clone ${{ gitea.server_url }}/${{ gitea.repository }} .
|
||||
git checkout ${{ gitea.ref_name }}
|
||||
|
||||
- name: Copy env
|
||||
run: |
|
||||
echo "${{ secrets.ENV_FILE }}" > .env
|
||||
cat .env
|
||||
|
||||
- name: Build & Push
|
||||
run: |
|
||||
docker build -t $REGISTRY/$IMAGE_NAME:${{ gitea.run_number }} .
|
||||
docker push $REGISTRY/$IMAGE_NAME:${{ gitea.run_number }}
|
||||
|
||||
deploy:
|
||||
runs-on: host
|
||||
needs: build_image
|
||||
steps:
|
||||
- name: Deploy container
|
||||
run: |
|
||||
docker run -d \
|
||||
--name $IMAGE_NAME \
|
||||
--memory="50m" \
|
||||
--network scheduler-net \
|
||||
--cpus="0.1" \
|
||||
--restart always \
|
||||
-p 9997:3000 \
|
||||
$REGISTRY/$IMAGE_NAME:${{ gitea.run_number }}
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
func NewDatabase() *gorm.DB {
|
||||
username := os.Getenv("DB_USERNAME")
|
||||
password := "123$Nt1"
|
||||
password := os.Getenv("DB_PASSWORD")
|
||||
port, err := strconv.Atoi(os.Getenv("DB_PORT"))
|
||||
if err != nil {
|
||||
fmt.Println("error ", err.Error())
|
||||
|
||||
1
main.go
1
main.go
@@ -17,7 +17,6 @@ func corsMiddleware(next http.Handler) http.Handler {
|
||||
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, FETCH")
|
||||
w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
|
||||
|
||||
// Untuk preflight request
|
||||
if r.Method == "OPTIONS" {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user