improved env in deploy
This commit is contained in:
parent
33166f08ff
commit
ea9e87e65b
2
.github/workflows/Deploy-docker.yml
vendored
2
.github/workflows/Deploy-docker.yml
vendored
@ -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
|
||||
|
||||
15
main.go
15
main.go
@ -5,6 +5,7 @@ import (
|
||||
"github.com/rs/cors"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"portfolio/api"
|
||||
"portfolio/database"
|
||||
"portfolio/web"
|
||||
@ -12,10 +13,12 @@ import (
|
||||
|
||||
func main() {
|
||||
// load .env in runtime environment
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
log.Fatalf(".env not found: %v", err)
|
||||
return
|
||||
if os.Getenv("ENVIRONMENT") != "docker" {
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
log.Fatalf(".env not found: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
//connect to database and migrate
|
||||
@ -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)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user