diff options
| -rw-r--r-- | Dockerfile | 7 | ||||
| -rw-r--r-- | cache/cache.go | 4 | ||||
| -rw-r--r-- | db/db.go | 2 |
3 files changed, 8 insertions, 5 deletions
@@ -7,7 +7,6 @@ COPY . /app/src WORKDIR /app/src RUN apk add git ca-certificates -RUN go mod download # Build image RUN CGO_ENABLED=0 GOOS=linux go build -o /go/bin/app @@ -16,10 +15,12 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o /go/bin/app FROM scratch # Copy app -COPY --from=builder /go/bin/app /go/bin/app +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY --from=builder /go/bin/app ./ +COPY .env ./ # Expose ports, change port to whatever you need to expose EXPOSE 8080 # Run app -ENTRYPOINT ["/go/bin/app"]
\ No newline at end of file +ENTRYPOINT ["./app"]
\ No newline at end of file diff --git a/cache/cache.go b/cache/cache.go index a8c4244..bac7ea8 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -25,6 +25,7 @@ func (c *Cache) Get(hash string) (db.Paste, error) { // check if hash in cache v, ok := c.m[hash] c.lock.RUnlock() + if ok { return v, nil } @@ -37,6 +38,7 @@ func (c *Cache) Get(hash string) (db.Paste, error) { func (c *Cache) add(p db.Paste) { c.lock.Lock() + defer c.lock.Unlock() + c.m[p.Hash] = p - c.lock.Unlock() } @@ -12,7 +12,7 @@ func init() { // load .env file err := godotenv.Load() if err != nil { - log.Fatal("Error loading .env file") + log.Fatal("Error loading .env file: %s", err.Error()) } mUser := os.Getenv("MONGO_USER") |