Skip to content

Commit

Permalink
Fix docker
Browse files Browse the repository at this point in the history
  • Loading branch information
slhmy committed Jan 14, 2024
1 parent 694dbf8 commit 66bbd2b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
7 changes: 2 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
.github/
.vscode/
test/
test-collection/
frontend/
postman/
oj-lab-services-structure.drawio
tests/
artifacts/
9 changes: 0 additions & 9 deletions docker/oj-lab-platform.dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM golang:latest as build

RUN mkdir /oj-lab-platform-build
WORKDIR /oj-lab-platform-build

COPY go.mod /oj-lab-platform-build/go.mod
Expand All @@ -19,21 +18,13 @@ RUN make get-front

FROM ubuntu:latest

RUN apt update && apt install -y make

RUN mkdir /workspace
WORKDIR /workspace

COPY --from=build /oj-lab-platform-build/artifacts/bin/service /usr/local/bin/oj-lab-service
COPY --from=build /oj-lab-platform-build/artifacts/bin/asynq_worker /usr/local/bin/asynq_worker

COPY --from=build /oj-lab-platform-build/artifacts/oj-lab-front /workspace/artifacts/oj-lab-front

COPY environment/configs/production.toml /workspace/environment/configs/production.toml

COPY Makefile /workspace/Makefile
COPY scripts/ /workspace/scripts/

ENV OJ_LAB_SERVICE_ENV=production
ENV OJ_LAB_PROJECT_ROOT=workspace
EXPOSE 8080
Expand Down
2 changes: 1 addition & 1 deletion environment/configs/production.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ level = "debug"
dsn = "user=postgres password=development host=host.docker.internal port=5432 dbname=oj_lab sslmode=disable TimeZone=Asia/Shanghai"

[redis]
host = "localhost:6379"
host = "host.docker.internal:6379"

[jwt]
secret = "example_secret"
Expand Down
19 changes: 17 additions & 2 deletions src/core/agent/redis/client.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
package redisAgent

import "github.com/redis/go-redis/v9"
import (
"github.com/OJ-lab/oj-lab-services/src/core"
"github.com/redis/go-redis/v9"
)

const (
redisHostProp = "redis.host"
)

var (
redisHost string
)

func init() {
redisHost = core.AppConfig.GetString(redisHostProp)
}

var redisClient *redis.Client

func GetDefaultRedisClient() *redis.Client {
if redisClient == nil {
redisClient = redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Addr: redisHost,
})
}
return redisClient
Expand Down

0 comments on commit 66bbd2b

Please sign in to comment.