some fixes for docker and migrations

This commit is contained in:
2025-10-31 00:17:48 +01:00
parent 84ec54a893
commit 8d908a0502
13 changed files with 202 additions and 26 deletions
+8 -4
View File
@@ -2,17 +2,21 @@ FROM golang:1.25.2-alpine3.22 AS builder
WORKDIR /app
COPY go.mod ./
COPY server/ ./server/
COPY pkg/ ./pkg/
COPY service_b/go.mod service_b/go.sum ./service_b/
COPY service_b/server/ ./service_b/server/
COPY service_b/internal/ ./service_b/internal/
WORKDIR /app/service_b
RUN go mod download
RUN go build -o /app/service_b ./server/main.go
RUN go build -o /app/bin/service_b ./server/main.go
FROM alpine:latest
WORKDIR /app
COPY --from=builder /app/service_b /app/service_b
COPY --from=builder /app/bin/service_b /app/service_b
EXPOSE 8090
+2 -1
View File
@@ -8,6 +8,7 @@ import (
"io"
"log/slog"
"net/http"
"os"
"time"
"github.com/cenkalti/backoff/v5"
@@ -42,7 +43,7 @@ func (s *Service) GetWeatherByCity(ctx context.Context, params GetMeteoData) (Me
toDate := fromDate.AddDate(0, 0, params.Days-1)
operation := func() (*http.Response, error) {
url := fmt.Sprintf("http://localhost:8080/data?city=%s&from=%s&to=%s",
url := fmt.Sprintf("%s/data?city=%s&from=%s&to=%s", os.Getenv("URL_SERVICE_A"),
params.Location, params.Date, toDate.Format("2006-01-02"))
slog.Info("url", "url", url)
+8
View File
@@ -4,11 +4,19 @@ import (
"fmt"
"log/slog"
"net/http"
"pkg"
"serviceb/internal/domains/meteo"
"serviceb/internal/router"
"time"
)
func init() {
err := pkg.LoadEnvFile("./../.env")
if err != nil {
slog.Warn("error loading env file", "error", err)
}
}
func main() {
mux := router.SetupRoutes()