Skip to content

Commit

Permalink
Merge pull request #1 from wutong-paas/noauth
Browse files Browse the repository at this point in the history
noauth -> master
  • Loading branch information
poneding committed Jun 25, 2023
2 parents 1b07c14 + 938c0e2 commit 79004f1
Show file tree
Hide file tree
Showing 13 changed files with 220 additions and 217 deletions.
6 changes: 3 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*
!docker/*
!filebrowser
# *
# !docker/*
# !filebrowser
8 changes: 8 additions & 0 deletions .filebrowser.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"port": 8080,
"baseURL": "",
"address": "",
"log": "stdout",
"database": "/Users/dp/temp/filebrowser.db",
"root": "/Users/dp/temp/filebrowser"
}
53 changes: 53 additions & 0 deletions .github/workflows/commit-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: commit-ci

env:
TITLE: filebrowser
BASE_VERSION: latest

on:
push:
branches: [noauth]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# - name: Set ENV
# run: |
# echo "VERSION=${BASE_VERSION}-beta-${GITHUB_SHA::7}" >> $GITHUB_ENV

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to myhuaweicloud-swr
uses: docker/login-action@v2
with:
registry: ${{ secrets.DOMESTIC_DOCKER_SERVER }}
username: ${{ secrets.DOMESTIC_DOCKER_USERNAME }}
password: ${{ secrets.DOMESTIC_DOCKER_PASSWORD }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm64
file: Dockerfile.multiarch
push: true
tags: ${{ secrets.DOMESTIC_DOCKER_SERVER }}/wutong/${{ env.TITLE }}:${{ env.BASE_VERSION }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

# - name: Deploy to dev cluster
# id: k8s_deploy
# uses: actions-hub/kubectl@master
# env:
# KUBE_CONFIG: ${{ secrets.DEV_KUBE_CONFIG }}
# with:
# args: set image deployment/${{ env.TITLE }} -n wt-system operator=${{ secrets.DOMESTIC_DOCKER_SERVER }}/wutong/${{ env.TITLE }}:${{ env.BASE_VERSION }}
100 changes: 0 additions & 100 deletions .github/workflows/main.yaml

This file was deleted.

11 changes: 7 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ build:
binary: filebrowser
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
Expand All @@ -31,7 +33,7 @@ dockers:
goos: linux
goarch: amd64
image_templates:
- "swr.cn-southwest-2.myhuaweicloud.com/wutong/filebrowser:latest"
- "wutongpaas/filebrowser:latest-amd64"
extra_files:
- docker_config.json

Expand All @@ -49,11 +51,12 @@ dockers:
goos: linux
goarch: arm64
image_templates:
- "swr.cn-southwest-2.myhuaweicloud.com/wutong/filebrowser:latest"
- "wutongpaas/filebrowser:latest-arm64"
extra_files:
- docker_config.json

docker_manifests:
- name_template: "swr.cn-southwest-2.myhuaweicloud.com/wutong/filebrowser:latest"
- name_template: "wutongpaas/filebrowser:latest"
image_templates:
- "swr.cn-southwest-2.myhuaweicloud.com/wutong/filebrowser:latest"
- "wutongpaas/filebrowser:latest-arm64"
- "wutongpaas/filebrowser:latest-amd64"
33 changes: 33 additions & 0 deletions Dockerfile.multiarch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Build the manager binary
FROM --platform=$TARGETPLATFORM golang:1.18 as builder
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
ENV GOPROXY=https://goproxy.cn,direct
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY . .

# Build
ARG TARGETOS TARGETARCH TARGETPLATFORM
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -a -o filebrowser main.go

FROM --platform=$TARGETPLATFORM alpine:latest AS final
RUN apk --update add ca-certificates \
mailcap \
curl

HEALTHCHECK --start-period=2s --interval=5s --timeout=3s \
CMD curl -f http://localhost/health || exit 1

VOLUME /srv
EXPOSE 80

COPY docker_config.json /.filebrowser.json
COPY --from=builder /workspace/filebrowser /filebrowser

CMD ["/filebrowser"]
10 changes: 5 additions & 5 deletions amd64-build.sh → build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
# 2. docker login dockerhub

export NAMESPACE=filebrowser
export VERSION=v1.0.0-stable
# docker buildx create --use --name filebrowserbuilder
docker buildx use filebrowserbuilder
docker buildx build --platform linux/arm64 --push -t wutongpaas/${NAMESPACE}:${VERSION} -f Dockerfile .
# docker buildx build --platform linux/arm64 --push -t swr.cn-southwest-2.myhuaweicloud.com/wutong/${NAMESPACE}:${VERSION} -f Dockerfile .
export VERSION=latest
docker buildx create --use --name filebrowserbuilder
# docker buildx use filebrowserbuilder
docker buildx build --platform linux/arm64 --push -t swr.cn-southwest-2.myhuaweicloud.com/wutong/${NAMESPACE}:${VERSION} -f Dockerfile.multiarch .
# docker buildx build --platform linux/arm64 --push -t swr.cn-southwest-2.myhuaweicloud.com/wutong/${NAMESPACE}:${VERSION} -f Dockerfile .
# docker buildx rm filebrowserbuilder
9 changes: 7 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func quickSetup(flags *pflag.FlagSet, d pythonData) {
CreateUserDir: false,
Defaults: settings.UserDefaults{
Scope: ".",
Locale: "en",
Locale: "zh-cn",
SingleClick: false,
Perm: users.Permissions{
Admin: false,
Expand Down Expand Up @@ -412,7 +412,12 @@ func initConfig() {
}

func customSetEnv() {
serviceID := os.Getenv("SERVICE_ID")
os.Setenv("FB_NOAUTH", "true")
serviceID := os.Getenv("WT_SERVICE_ID")
if len(serviceID) == 0 {
// 兼容旧的环境变量
serviceID = os.Getenv("SERVICE_ID")
}
if len(serviceID) > 0 {
os.Setenv("FB_BASEURL", "/console/filebrowser/"+serviceID)
}
Expand Down
Loading

0 comments on commit 79004f1

Please sign in to comment.