From d0e61d12473975bf68fc520a584d9e5e0153a1b2 Mon Sep 17 00:00:00 2001 From: Justin Hawkins Date: Wed, 22 Nov 2023 08:32:20 +1030 Subject: [PATCH] Prepare for goreleaser --- .goreleaser.yaml | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 50 ++++++--------------------------------------- 2 files changed, 59 insertions(+), 44 deletions(-) create mode 100644 .goreleaser.yaml diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..71ca99b --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,53 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com + +# The lines below are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/need to use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 1 + +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip + +# changelog: +# sort: asc +# filters: +# exclude: +# - "^docs:" +# - "^test:" + +dockers: + - image_templates: + - "tardisx/gropple:{{ .Tag }}" + - "tardisx/gropple:v{{ .Major }}" + - "tardisx/gropple:v{{ .Major }}.{{ .Minor }}" + - "tardisx/gropple:latest" + + diff --git a/Dockerfile b/Dockerfile index 16e7923..a0b924b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,47 +1,9 @@ -# Start from golang base image -FROM golang:alpine as builder +FROM ubuntu:mantic +COPY gropple / -# Install git. (alpine image does not have git in it) -RUN apk update && apk add --no-cache git curl - -# Set current working directory -WORKDIR /app - -RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /app/yt-dlp -RUN chmod a+x /app/yt-dlp - -# Note here: To avoid downloading dependencies every time we -# build image. Here, we are caching all the dependencies by -# first copying go.mod and go.sum files and downloading them, -# to be used every time we build the image if the dependencies -# are not changed. - -# Copy go mod and sum files -COPY go.mod ./ -COPY go.sum ./ - -# Download all dependencies. -RUN go mod download - -# Now, copy the source code -COPY . . - -# Note here: CGO_ENABLED is disabled for cross system compilation -# It is also a common best practise. - -# Build the application. -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/gropple . - -# Finally our multi-stage to build a small image -# Start a new stage from scratch -FROM golang:alpine - -# Copy the Pre-built binary file -COPY --from=builder /app/bin/gropple . -COPY --from=builder /app/yt-dlp /bin/ - -# Install things we need to support yt-dlp -RUN apk update && apk add --no-cache python3 ffmpeg +RUN apt update && apt install -y curl python3 ffmpeg +RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/bin/yt-dlp +RUN chmod a+x /usr/bin/yt-dlp # Run executable -CMD ["./gropple", "--config-path", "/config/gropple.json"] +CMD ["/gropple", "--config-path", "/config/gropple.json"]