Skip to content

Commit

Permalink
fix config issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Xunop committed Jul 20, 2024
1 parent f2de6da commit 7a25b58
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/dev-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ jobs:

- name: Deploy in server
uses: appleboy/[email protected]
env:
WORKINGDIR: ${{ secrets.WORKINGDIR }}
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script_stop: true
envs: WORKINGDIR
script: |
### Notice: run for develop ###
# Stop and remove existing container if it exists
Expand All @@ -61,7 +64,7 @@ jobs:
# Load the new image and run it
# It will failed, for test
docker load -i /tmp/image.tar
docker run -d --name sastlink -p 8080:8080 sast/sast-link
docker run --restart always -d --name sastlink -p 8080:8080 -v $WORKINGDIR:/sastlink/config sast/sast-link
- name: Send Success Message
if: ${{ success() }}
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM golang:1.22 AS builder

ADD src /sastlink
ENV GO111MODULE=on
# ENV GOPROXY=https://goproxy.cn
ENV GOPROXY=https://goproxy.cn
RUN cd /sastlink && CGO_ENABLED=0 go build

# ----------------------------------------------------------------
Expand All @@ -14,7 +14,7 @@ RUN cd /sastlink && CGO_ENABLED=0 go build
FROM alpine

COPY --from=builder /sastlink /sastlink
COPY --from=builder /sastlink/config /config
WORKDIR /sastlink

# This container exposes port 8080 to the outside world
EXPOSE 8080
Expand Down
6 changes: 6 additions & 0 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ func init() {
Config.SetConfigName(fileName)
Config.SetConfigType("toml")

// Get current working directory
currentDir, err := os.Getwd()
if err != nil {
panic(err.Error())
}
fmt.Printf("Current working directory: %s\n", currentDir)
if err := Config.ReadInConfig(); err != nil {
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
panic(fmt.Sprintf("File [config/%s.toml] Not Found\n", fileName))
Expand Down

0 comments on commit 7a25b58

Please sign in to comment.