Prepare for goreleaser
This commit is contained in:
parent
746a65dc80
commit
d0e61d1247
53
.goreleaser.yaml
Normal file
53
.goreleaser.yaml
Normal file
@ -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"
|
||||
|
||||
|
50
Dockerfile
50
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"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user