diff --git a/.drone.dockerfile b/.drone.dockerfile deleted file mode 100644 index f99360b2e..000000000 --- a/.drone.dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM ubuntu:20.04 as temp -RUN apt update && apt install -y wget ca-certificates - -ARG DRONE_TAG - -RUN wget -O /tmp/xbvr.tgz "https://github.com/xbapps/xbvr/releases/download/"$DRONE_TAG"/xbvr_"$DRONE_TAG"_Linux_x86_64.tar.gz" && \ - tar xvfz /tmp/xbvr.tgz -C /usr/local/bin/ && \ - rm /tmp/xbvr.tgz - -FROM gcr.io/distroless/base-debian10 -COPY --from=temp /usr/local/bin/xbvr / - -EXPOSE 9998-9999 -VOLUME /root/.config/ - -ENTRYPOINT ["/xbvr"] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d4e980f05..996062c3d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,11 +11,18 @@ jobs: runs-on: ubuntu-latest + env: + DOCKER_CLI_EXPERIMENTAL: "enabled" + steps: - name: Checkout code uses: actions/checkout@v2 with: submodules: 'true' + fetch-depth: 0 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 - name: Build UI run: cd ui && yarn install && yarn build @@ -23,6 +30,10 @@ jobs: - name: Setup release environment run: |- echo 'GITHUB_TOKEN=${{secrets.GORELEASER_ACCESS_TOKEN}}' > .release-env + echo 'GITHUB_USER=${{github.event.repository.owner.login}}' >> .release-env + echo 'GITHUB_PROJECT=${{github.event.repository.name}}' >> .release-env + echo 'DOCKER_CREDS_FILE=.docker-creds' >> .release-env + echo '${{github.event.repository.owner.login}}:${{secrets.GORELEASER_ACCESS_TOKEN}}:ghcr.io' >> .docker-creds - name: Release publish run: make release diff --git a/.gitignore b/.gitignore index e48fb0ca9..1fedac73a 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,6 @@ node_modules/ /ui/public/static/bundle.* npm-debug.log yarn-error.log + .release-env +.docker-creds diff --git a/.goreleaser.yml b/.goreleaser.yml index 68a455642..870b146b5 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -4,7 +4,7 @@ before: - go generate ./... builds: -- id: xbvr-mac +- id: xbvr-mac-intel binary: xbvr # main: pkg/tray/main.go flags: @@ -22,6 +22,24 @@ builds: # hooks: # post: ./appify.sh -s ./dist/xbvr-mac_darwin_amd64/XBVR.app/Contents/MacOS/XBVR -i ./ui/public/icons/xbvr-mac.icns -n XBVR +- id: xbvr-mac-m1 + binary: xbvr +# main: pkg/tray/main.go + flags: + - -tags=json1 + ldflags: + - -s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} + env: + - CGO_ENABLED=1 + - CC=o64-clang + - CXX=o64-clang++ + goos: + - darwin + goarch: + - arm64 +# hooks: +# post: ./appify.sh -s ./dist/xbvr-mac_darwin_amd64/XBVR.app/Contents/MacOS/XBVR -i ./ui/public/icons/xbvr-mac.icns -n XBVR + - id: xbvr-windows binary: xbvr main: pkg/tray/main.go @@ -61,6 +79,48 @@ builds: goarch: - arm64 +dockers: + - + use: buildx + dockerfile: Dockerfile + goos: linux + goarch: amd64 + image_templates: + - ghcr.io/{{.Env.GITHUB_USER}}/{{.Env.GITHUB_PROJECT}}:{{ .Version }}-amd64 + build_flag_templates: + - --platform=linux/amd64 + - --no-cache + - --label=org.opencontainers.image.source=https://github.com/{{.Env.GITHUB_USER}}/{{.Env.GITHUB_PROJECT}} + - --label=org.opencontainers.image.title={{ .ProjectName }} + - --label=org.opencontainers.image.version={{ .Version }} + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} + - + use: buildx + dockerfile: Dockerfile + goos: linux + goarch: arm64 + image_templates: + - ghcr.io/{{.Env.GITHUB_USER}}/{{.Env.GITHUB_PROJECT}}:{{ .Version }}-arm64 + build_flag_templates: + - --platform=linux/arm64 + - --no-cache + - --label=org.opencontainers.image.source=https://github.com/{{.Env.GITHUB_USER}}/{{.Env.GITHUB_PROJECT}} + - --label=org.opencontainers.image.title={{ .ProjectName }} + - --label=org.opencontainers.image.version={{ .Version }} + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} + +docker_manifests: + - name_template: ghcr.io/{{.Env.GITHUB_USER}}/{{.Env.GITHUB_PROJECT}}:{{ .Version }} + image_templates: + - ghcr.io/{{.Env.GITHUB_USER}}/{{.Env.GITHUB_PROJECT}}:{{ .Version }}-amd64 + - ghcr.io/{{.Env.GITHUB_USER}}/{{.Env.GITHUB_PROJECT}}:{{ .Version }}-arm64 + - name_template: ghcr.io/{{.Env.GITHUB_USER}}/{{.Env.GITHUB_PROJECT}}:latest + image_templates: + - ghcr.io/{{.Env.GITHUB_USER}}/{{.Env.GITHUB_PROJECT}}:{{ .Version }}-amd64 + - ghcr.io/{{.Env.GITHUB_USER}}/{{.Env.GITHUB_PROJECT}}:{{ .Version }}-arm64 + archives: - id: archive-linux builds: @@ -78,10 +138,13 @@ archives: windows: Windows - id: archive-mac builds: - - xbvr-mac + - xbvr-mac-intel + - xbvr-mac-m1 format: zip replacements: darwin: macOS + amd64: intel + arm64: m1 # files: # - XBVR.app/Contents/Resources/XBVR.icns # - XBVR.app/Contents/Info.plist @@ -89,15 +152,25 @@ archives: snapshot: name_template: "{{ .Tag }}-next" +checksum: + name_template: "checksums.txt" + changelog: + use: github sort: asc + groups: + - title: Features + regexp: "^.*feat[(\\w)]*:+.*$" + order: 0 + - title: 'Bug fixes' + regexp: "^.*fix[(\\w)]*:+.*$" + order: 1 + - title: Others + order: 999 filters: exclude: - - '^docs:' - - '^test:' + - "^docs:" + - "^test:" release: disable: false - github: - owner: xbapps - name: xbvr diff --git a/Dockerfile b/Dockerfile index 549fe29f7..307d9282b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,12 @@ -FROM node:12 as build-env +FROM ubuntu:20.04 -### Install Go ### -ENV GO_VERSION=1.17.5 \ - GOPATH=$HOME/go-packages \ - GOROOT=$HOME/go -ENV PATH=$GOROOT/bin:$GOPATH/bin:$PATH -RUN curl -fsSL https://storage.googleapis.com/golang/go$GO_VERSION.linux-amd64.tar.gz | tar -xzv +RUN apt-get update && \ + apt-get install -y --no-install-recommends python3 ca-certificates && \ + rm -rf /var/lib/apt/lists/* -WORKDIR /app -ADD . /app -RUN cd /app && \ - yarn install && \ - yarn build && \ - go generate && \ - go build -tags='json1' -ldflags '-w' -o xbvr main.go - -FROM gcr.io/distroless/base -COPY --from=build-env /app/xbvr / +COPY xbvr /usr/bin/xbvr EXPOSE 9998-9999 VOLUME /root/.config/ -ENTRYPOINT ["/xbvr"] +CMD ["/usr/bin/xbvr"] diff --git a/README.md b/README.md index fa4a87860..dfdf3658a 100644 --- a/README.md +++ b/README.md @@ -44,9 +44,9 @@ To run this container in docker: ``` docker run -t --name=xbvr --net=host --restart=always \ - --mount type=bind,source=/path/to/your/videos,target=/videos,readonly \ + --mount type=bind,source=/path/to/your/videos,target=/videos \ --mount source=xbvr-config,target=/root/.config/ \ - xbapps/xbvr:latest + ghcr.io/xbapps/xbvr:latest ``` Adding `-d` to the docker command will run the container in the background.