Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: Linter

on:
push:
paths:
- "**/*.go"
- ".github/workflows/linter.yml"
pull_request:
types: [opened, synchronize, reopened]
paths:
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/release-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release-Docker

on:
release:
types: [published]

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Set build time
run: |
echo "BUILD_TIME=$(date +%FT%T%z)" >> $GITHUB_ENV
-
name: Build and push
uses: docker/build-push-action@v4
with:
platforms: linux/arm64,linux/amd64
push: true
file: ./scripts/Dockerfile
tags: gosonic/sonic:test
build-args: |
SONIC_VERSION=${{github.ref_name}}
BUILD_COMMIT=${{github.sha}}
BUILD_TIME=${{env.BUILD_TIME}}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Show workflow information
run: |
echo "GOOS: $GOOS, GOARCH: $GOARCH"
echo "BUILD_TIME=$(date --rfc-3339=seconds)" >> $GITHUB_ENV
echo "BUILD_TIME=$(date +%FT%T%z)" >> $GITHUB_ENV

- name: Build
uses: crazy-max/ghaction-xgo@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/upload
/.vscode
sonic.db
sonic
__debug_bin
/resources/template/theme/
!/resources/template/theme/default-theme-anatole
20 changes: 12 additions & 8 deletions scripts/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
FROM golang:1.19.3-alpine as builder

RUN apk --no-cache add git ca-certificates gcc g++

WORKDIR /go/src/github.com/go-sonic/

RUN git clone --recursive --depth 1 https://github.com/go-sonic/sonic.git

COPY . /go/src/github.com/go-sonic/sonic/
WORKDIR /go/src/github.com/go-sonic/sonic

RUN GOPROXY=https://goproxy.cn CGO_ENABLED=1 GOOS=linux go build -o sonic -ldflags="-s -w" -trimpath .
ARG BUILD_COMMIT
ARG BUILD_TIME
ARG SONIC_VERSION


RUN CGO_ENABLED=1 GOOS=linux && \
go build -o sonic -ldflags="-s -w -X github.com/go-sonic/sonic/consts.SonicVersion=${SONIC_VERSION} -X github.com/go-sonic/sonic/consts.BuildCommit=${BUILD_COMMIT} -X github.com/go-sonic/sonic/consts.BuildTime=${BUILD_TIME}" -trimpath .

RUN mkdir -p /app/conf && \
mkdir /app/resources && \
Expand All @@ -17,12 +19,14 @@ RUN mkdir -p /app/conf && \
cp -r /go/src/github.com/go-sonic/sonic/resources /app/ && \
cp /go/src/github.com/go-sonic/sonic/scripts/docker_init.sh /app/




FROM alpine:latest as prod

COPY --from=builder /app/ /app/

RUN apk update \
&& apk add --no-cache tzdata \
RUN apk add --no-cache tzdata \
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone

Expand Down