generated from Caknoooo/go-gin-clean-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add azure support and workflow
feat: add azure support and workflow
- Loading branch information
Showing
7 changed files
with
100 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Build Go app and push to Azure (Development) | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.18 | ||
|
||
- name: Build | ||
run: go build -o build/go-app.exe -v | ||
|
||
- name: Deploy to Azure | ||
uses: Azure/webapps-deploy@v2 | ||
with: | ||
# Name of the Azure Web App | ||
app-name: tedxits-dev | ||
# Applies to Web App only: Path to package or folder. *.zip, *.war, *.jar or a folder to deploy | ||
package: build/ | ||
publish-profile: ${{ secrets.AZUREWEBAPPPUBLISHPROFILEDEVELOPMENT }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
<system.webServer> | ||
<handlers> | ||
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" /> | ||
</handlers> | ||
<httpPlatform processPath="D:\home\site\wwwroot\go-app.exe" startupTimeLimit="60"> | ||
</httpPlatform> | ||
</system.webServer> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,10 @@ | ||
version: '3.9' | ||
|
||
services: | ||
postgres: | ||
hostname: postgres | ||
image: postgres:latest | ||
ports: | ||
- ${DB_PORT}:5432 | ||
volumes: | ||
- ./volumes/postgres:/var/lib/postgresql/data | ||
container_name: tedxits2024 | ||
image: postgres | ||
environment: | ||
- POSTGRES_USER=${DB_USER} | ||
- POSTGRES_PASSWORD=${DB_PASS} | ||
- POSTGRES_DB=${DB_NAME} | ||
networks: | ||
- app-network | ||
|
||
app: | ||
hostname: app | ||
container_name: golang-clean-template | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
- POSTGRES_USER=postgres | ||
- POSTGRES_PASSWORD=password | ||
- POSTGRES_DB=tedxits2024 | ||
ports: | ||
- ${GOLANG_PORT}:${GOLANG_PORT} | ||
restart: always | ||
volumes: | ||
- ./:/app | ||
depends_on: | ||
- postgres | ||
env_file: | ||
- .env | ||
networks: | ||
- app-network | ||
|
||
volumes: | ||
app_vol: | ||
|
||
networks: | ||
app-network: | ||
driver: bridge | ||
- 5432:5432 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package azure | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
|
||
"github.com/fsnotify/fsnotify" | ||
) | ||
|
||
func StopOnNewDeployment() { | ||
// creates a new file watcher for App_offline.htm | ||
watcher, err := fsnotify.NewWatcher() | ||
if err != nil { | ||
fmt.Println("ERROR", err) | ||
} | ||
defer watcher.Close() | ||
|
||
// watch for App_offline.htm and exit the program if present | ||
// This allows continuous deployment on App Service as the .exe will not be | ||
// terminated otherwise | ||
go func() { | ||
for { | ||
select { | ||
case event := <-watcher.Events: | ||
if strings.HasSuffix(event.Name, "app_offline.htm") { | ||
fmt.Println("Exiting due to app_offline.htm being present") | ||
os.Exit(0) | ||
} | ||
} | ||
} | ||
}() | ||
|
||
// get the current working directory and watch it | ||
currentDir, err := os.Getwd() | ||
if err := watcher.Add(currentDir); err != nil { | ||
fmt.Println("ERROR", err) | ||
} | ||
} |