improved env in deploy
Some checks failed
build and deploy portfolio / build (push) Failing after 4s
build and deploy portfolio / publish-docs (push) Has been skipped
build and deploy portfolio / publish-portfolio (push) Has been skipped

This commit is contained in:
darius 2025-02-25 18:48:29 +01:00
parent 33166f08ff
commit ea9e87e65b
2 changed files with 11 additions and 6 deletions

View File

@ -14,6 +14,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Setup env file
run: echo ${{secrets.envFile}} >> .env
- name: Build the Docker image
run: docker compose build
- name: Docker login

View File

@ -5,6 +5,7 @@ import (
"github.com/rs/cors"
"log"
"net/http"
"os"
"portfolio/api"
"portfolio/database"
"portfolio/web"
@ -12,11 +13,13 @@ import (
func main() {
// load .env in runtime environment
if os.Getenv("ENVIRONMENT") != "docker" {
err := godotenv.Load()
if err != nil {
log.Fatalf(".env not found: %v", err)
return
}
}
//connect to database and migrate
database.DB()
@ -25,7 +28,7 @@ func main() {
webMux := web.Routes()
// Run web server
go func() {
err = http.ListenAndServe(":4000", cors.AllowAll().Handler(webMux))
err := http.ListenAndServe(":4000", cors.AllowAll().Handler(webMux))
if err != nil {
log.Fatal(err)
@ -50,7 +53,7 @@ func main() {
apiMux := api.Routes()
//run api server
go func() {
err = http.ListenAndServe(":4001", c.Handler(apiMux))
err := http.ListenAndServe(":4001", c.Handler(apiMux))
if err != nil {
log.Fatal(err)
}