Ver Fonte

fix: fix Dockerfile

JustSong há 2 anos atrás
pai
commit
00ee736e13
3 ficheiros alterados com 54 adições e 3 exclusões
  1. 50 0
      .github/workflows/docker-image.yml
  2. 3 2
      Dockerfile
  3. 1 1
      common/constants.go

+ 50 - 0
.github/workflows/docker-image.yml

@@ -0,0 +1,50 @@
+name: Publish Docker image
+
+on:
+  push:
+    tags:
+      - '*'
+  workflow_dispatch:
+    inputs:
+      name:
+        description: 'reason'
+        required: false
+jobs:
+  push_to_registries:
+    name: Push Docker image to multiple registries
+    runs-on: ubuntu-latest
+    permissions:
+      packages: write
+      contents: read
+    steps:
+      - name: Check out the repo
+        uses: actions/checkout@v3
+
+      - name: Log in to Docker Hub
+        uses: docker/login-action@v2
+        with:
+          username: ${{ secrets.DOCKERHUB_USERNAME }}
+          password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+      - name: Log in to the Container registry
+        uses: docker/login-action@v2
+        with:
+          registry: ghcr.io
+          username: ${{ github.actor }}
+          password: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Extract metadata (tags, labels) for Docker
+        id: meta
+        uses: docker/metadata-action@v4
+        with:
+          images: |
+            justsong/message-pusher
+            ghcr.io/${{ github.repository }}
+
+      - name: Build and push Docker images
+        uses: docker/build-push-action@v3
+        with:
+          context: .
+          push: true
+          tags: ${{ steps.meta.outputs.tags }}
+          labels: ${{ steps.meta.outputs.labels }}

+ 3 - 2
Dockerfile

@@ -6,20 +6,21 @@ RUN npm install
 RUN npm run build
 
 FROM golang AS builder2
+
 ENV GO111MODULE=on \
     CGO_ENABLED=1 \
     GOOS=linux \
     GOARCH=amd64
-
 WORKDIR /build
 COPY . .
 COPY --from=builder /build/build ./web/build
 RUN go mod download
-RUN go build -ldflags "-s -w" -o message-pusher
+RUN go build -ldflags "-s -w -extldflags '-static'" -o message-pusher
 
 FROM scratch
 
 ENV PORT=3000
 COPY --from=builder2 /build/message-pusher /
 EXPOSE 3000
+WORKDIR /data
 ENTRYPOINT ["/message-pusher"]

+ 1 - 1
common/constants.go

@@ -15,7 +15,7 @@ var Footer = ""
 // Any options with "Secret", "Token" in its key won't be return by GetOptions
 
 var SessionSecret = uuid.New().String()
-var SQLitePath = ".message-pusher.db"
+var SQLitePath = "message-pusher.db"
 
 var OptionMap map[string]string
 var OptionMapRWMutex sync.RWMutex