diff --git a/.dockerignore b/.dockerignore index 41108087..4a013aa4 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,4 @@ -backend/database.db +backend/**.db backend/vendor/** frontend/dist/** frontend/node_modules/** \ No newline at end of file diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 42ae7c60..80ea3969 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -3,98 +3,57 @@ name: main on: push: branches: - - 'master' - tags: - - 'v*' + - 'main' + - 'v\d+.\d+.\d+' pull_request: - + branches: + - 'main' + - 'v\d+.\d+.\d+' jobs: -# linters - lint-frontend: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: '16' - - run: make lint-frontend - lint-backend: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 - with: - go-version: 1.20.1 - - run: make lint-backend - lint-commits: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - uses: actions/setup-node@v2 - with: - node-version: '16' - - run: make lint-commits - lint: - runs-on: ubuntu-latest - needs: [lint-frontend, lint-backend, lint-commits] - steps: - - run: echo "done" - -# tests - test-frontend: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: '16' - - run: make test-frontend - test-backend: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 - with: - go-version: 1.20.1 - - run: make test-backend test: runs-on: ubuntu-latest - needs: [test-frontend, test-backend] steps: - - run: echo "done" - -# release - release: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: 1.21.1 + - run: cd backend && go test -race -v ./... + lint: runs-on: ubuntu-latest - needs: [lint, test] - if: startsWith(github.event.ref, 'refs/tags/v') steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 with: - fetch-depth: 0 - - uses: actions/setup-go@v2 - with: - go-version: 1.20.1 - - uses: actions/setup-node@v2 - with: - node-version: '16' + go-version: 1.21.1 + - run: cd backend && go fmt ./... + push_to_registry: + needs: [lint, test] + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + if: contains(github.ref, 'main') || startsWith(github.ref,'v0.') + steps: + - name: Check out the repo + uses: actions/checkout@v4 - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - name: Build frontend - run: make build-frontend - - name: Login to Docker Hub - uses: docker/login-action@v1 + uses: docker/setup-buildx-action@v3 + - name: Log in to Docker Hub + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: - version: latest - args: release --rm-dist - env: - GITHUB_TOKEN: ${{ secrets.GH_PAT }} + images: gtstef/filebrowser + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64,linux/arm/v7 + file: ./Dockerfile + push: true + tags: ${{ contains(github.ref, 'main') && 'latest' || steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yaml similarity index 88% rename from .github/workflows/stale.yml rename to .github/workflows/stale.yaml index 60c6ae5e..c7b8f58f 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yaml @@ -16,9 +16,9 @@ jobs: stale-pr-message: 'This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.' close-pr-message: 'This PR was closed because it has been stalled for 5 days with no activity.' stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.' - close-issue-message: 'This issue was closed because it has been stalled for 5 days with no activity.' + close-issue-message: 'This issue was closed because it has been stalled for 30 days with no activity.' days-before-stale: 30 - days-before-close: 5 + days-before-close: 30 exempt-issue-labels: 'feature ☘,enhancement ⚙,bug 🐞' exempt-pr-labels: 'need-help,wip' operations-per-run: 100 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 070266d6..5df9a358 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,7 @@ RUN npm run build FROM golang:1.21-alpine as base WORKDIR /app COPY ./backend ./ +RUN go get -u golang.org/x/net RUN go build -ldflags="-w -s" -o filebrowser . FROM alpine:latest diff --git a/README.md b/README.md index c317a247..d872efd2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -
diff --git a/backend/go.mod b/backend/go.mod
index 107622c5..83bc14f3 100644
--- a/backend/go.mod
+++ b/backend/go.mod
@@ -1,6 +1,6 @@
module github.com/gtsteffaniak/filebrowser
-go 1.21.0
+go 1.21
require (
github.com/asdine/storm/v3 v3.2.1
diff --git a/frontend/package.json b/frontend/package.json
index 00c529e1..87f6487c 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -6,7 +6,10 @@
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"fix": "npx vue-cli-service lint",
- "watch": "vue-cli-service build --watch"
+ "watch": "vue-cli-service build --watch",
+ "lint": "eslint --ext .vue,.js src/",
+ "lint:fix": "eslint --ext .vue,.js --fix src/",
+ "format": "prettier --write ."
},
"dependencies": {
"ace-builds": "^1.24.2",