Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Dockerfile's Go & Alpine versions #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

teapot9
Copy link

@teapot9 teapot9 commented Sep 29, 2024

Update Go to 1.22 and Alpine to 3.20 and change Dockerfile accordingly.

Add go build command.
Run chmod on /go/src/github.com/andreimarcu/linx-server to make static & templates directories readable by the server (only needed when image is built with UMASK=0027).

@vlnst
Copy link

vlnst commented Oct 6, 2024

You can probably just use go install -v . instead of go get -v . and go build -o /go/bin/linx-server . (tested it on my setup).

The program launches with latest go, but I'm not use if using a go version other than what is stated in go.mod is okay

@vlnst

This comment was marked as resolved.

Update Go to 1.22 and Alpine to 3.20 and change Dockerfile accordingly.

Add `go build` command.
Run chmod on /go/src/github.com/andreimarcu/linx-server to make static &
templates directories readable by the server (only needed when image is
built with UMASK=0027).
@teapot9
Copy link
Author

teapot9 commented Oct 18, 2024

You can probably just use go install -v . instead of go get -v . and go build -o /go/bin/linx-server . (tested it on my setup).

The program launches with latest go, but I'm not use if using a go version other than what is stated in go.mod is okay

Tested and changed it, thanks!

@teapot9
Copy link
Author

teapot9 commented Oct 18, 2024

Also, there is a warning after build: WARNING: current commit information was not captured by the build: failed to read current commit information with git rev-parse --is-inside-work-tree which I guess should be fixed

I don't get the warning which makes it hard to troubleshoot...

My build log:

$ docker build --no-cache .
[1/2] STEP 1/4: FROM golang:1.22-alpine3.20 AS build
[1/2] STEP 2/4: COPY . /go/src/github.com/andreimarcu/linx-server
--> dff0d961f9e1
[1/2] STEP 3/4: WORKDIR /go/src/github.com/andreimarcu/linx-server
--> 93605a1cfa69
[1/2] STEP 4/4: RUN set -ex         && apk add --no-cache --virtual .build-deps git     && go install -v .         && apk del .build-deps
+ apk add --no-cache --virtual .build-deps git
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/community/x86_64/APKINDEX.tar.gz
(1/13) Installing brotli-libs (1.1.0-r2)
(2/13) Installing c-ares (1.33.1-r0)
(3/13) Installing libunistring (1.2-r0)
(4/13) Installing libidn2 (2.3.7-r0)
(5/13) Installing nghttp2-libs (1.62.1-r0)
(6/13) Installing libpsl (0.21.5-r1)
(7/13) Installing zstd-libs (1.5.6-r0)
(8/13) Installing libcurl (8.10.1-r0)
(9/13) Installing libexpat (2.6.3-r0)
(10/13) Installing pcre2 (10.43-r0)
(11/13) Installing git (2.45.2-r0)
(12/13) Installing git-init-template (2.45.2-r0)
(13/13) Installing .build-deps (20241018.074653)
Executing busybox-1.36.1-r29.trigger
OK: 20 MiB in 28 packages
+ go install -v .
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading github.com/GeertJohan/go.rice v1.0.3
go: downloading github.com/dchest/uniuri v1.2.0
go: downloading github.com/flosch/pongo2 v0.0.0-20200913210552-0d938eb266f3
go: downloading github.com/gabriel-vasile/mimetype v1.4.4
go: downloading github.com/microcosm-cc/bluemonday v1.0.26
go: downloading github.com/vharitonsky/iniflags v0.0.0-20180513140207-a33cd0b5f3de
go: downloading github.com/zeebo/bencode v1.0.0
go: downloading github.com/russross/blackfriday v1.6.0
go: downloading github.com/zenazn/goji v1.0.1
go: downloading golang.org/x/crypto v0.24.0
go: downloading github.com/aws/aws-sdk-go v1.54.9
go: downloading github.com/minio/sha256-simd v1.0.1
go: downloading github.com/daaku/go.zipexe v1.0.2
go: downloading github.com/aymerick/douceur v0.2.0
go: downloading golang.org/x/net v0.26.0
go: downloading github.com/klauspost/cpuid/v2 v2.2.8
go: downloading github.com/gorilla/css v1.0.1
go: downloading github.com/jmespath/go-jmespath v0.4.0
internal/godebugs
internal/coverage/rtcov
internal/goos
internal/goarch
internal/goexperiment
internal/itoa
internal/race
internal/cpu
internal/unsafeheader
runtime/internal/syscall
runtime/internal/atomic
sync/atomic
math/bits
unicode/utf8
encoding
unicode
cmp
unicode/utf16
internal/abi
internal/chacha8rand
runtime/internal/math
runtime/internal/sys
log/internal
container/list
crypto/internal/alias
crypto/subtle
vendor/golang.org/x/crypto/cryptobyte/asn1
crypto/internal/boring/sig
internal/nettrace
vendor/golang.org/x/crypto/internal/alias
golang.org/x/net/html/atom
github.com/aws/aws-sdk-go/aws/client/metadata
slices
internal/bytealg
math
github.com/aws/aws-sdk-go/internal/sdkmath
runtime
internal/reflectlite
sync
internal/testlog
internal/singleflight
internal/bisect
github.com/aws/aws-sdk-go/internal/sync/singleflight
internal/godebug
errors
sort
math/rand
internal/intern
internal/oserror
path
io
internal/safefilepath
vendor/golang.org/x/net/dns/dnsmessage
strconv
crypto/internal/nistec/fiat
syscall
hash
internal/saferio
crypto/internal/randutil
github.com/aws/aws-sdk-go/internal/sdkio
bytes
strings
hash/crc32
hash/adler32
crypto
crypto/rc4
reflect
net/netip
vendor/golang.org/x/text/transform
net/http/internal/ascii
github.com/aws/aws-sdk-go/internal/strings
bufio
github.com/aws/aws-sdk-go/internal/sdkuri
github.com/aws/aws-sdk-go/aws/arn
regexp/syntax
compress/bzip2
internal/syscall/execenv
internal/syscall/unix
time
regexp
github.com/microcosm-cc/bluemonday/css
github.com/andreimarcu/linx-server/expiry
github.com/aws/aws-sdk-go/internal/sdkrand
io/fs
internal/poll
context
internal/fmtsort
encoding/binary
embed
os
crypto/cipher
encoding/base64
crypto/md5
crypto/internal/edwards25519/field
vendor/golang.org/x/crypto/internal/poly1305
crypto/internal/nistec
encoding/pem
crypto/internal/edwards25519
crypto/internal/boring
vendor/golang.org/x/crypto/chacha20
crypto/des
crypto/hmac
crypto/sha256
crypto/sha1
crypto/sha512
crypto/aes
golang.org/x/crypto/pbkdf2
vendor/golang.org/x/crypto/hkdf
github.com/andreimarcu/linx-server/torrent
crypto/ecdh
golang.org/x/crypto/scrypt
io/ioutil
os/signal
path/filepath
fmt
vendor/golang.org/x/sys/cpu
net
vendor/golang.org/x/crypto/chacha20poly1305
os/exec
github.com/GeertJohan/go.rice/embedded
log
net/url
internal/zstd
encoding/hex
vendor/golang.org/x/net/http2/hpack
mime/quotedprintable
net/http/internal
encoding/json
flag
mime
debug/dwarf
vendor/golang.org/x/text/unicode/norm
compress/flate
math/big
os/user
encoding/xml
golang.org/x/net/html
encoding/csv
vendor/golang.org/x/text/unicode/bidi
archive/tar
github.com/gabriel-vasile/mimetype/internal/json
github.com/aws/aws-sdk-go/aws/awserr
github.com/aws/aws-sdk-go/internal/shareddefaults
github.com/aws/aws-sdk-go/internal/s3shared/arn
github.com/flosch/pongo2
github.com/aymerick/douceur/css
archive/zip
compress/gzip
compress/zlib
github.com/klauspost/cpuid/v2
vendor/golang.org/x/text/secure/bidirule
github.com/gorilla/css/scanner
github.com/aws/aws-sdk-go/internal/ini
github.com/russross/blackfriday
github.com/zeebo/bencode
runtime/debug
github.com/aymerick/douceur/parser
github.com/gabriel-vasile/mimetype/internal/charset
github.com/microcosm-cc/bluemonday
debug/macho
debug/pe
debug/elf
vendor/golang.org/x/net/idna
github.com/aws/aws-sdk-go/aws/credentials
github.com/jmespath/go-jmespath
github.com/aws/aws-sdk-go/aws/endpoints
github.com/aws/aws-sdk-go/aws/credentials/processcreds
github.com/gabriel-vasile/mimetype/internal/magic
github.com/minio/sha256-simd
crypto/rand
crypto/internal/bigmod
crypto/internal/boring/bbig
encoding/asn1
crypto/dsa
github.com/dustin/go-humanize
crypto/elliptic
github.com/daaku/go.zipexe
crypto/ed25519
github.com/dchest/uniuri
github.com/aws/aws-sdk-go/aws/awsutil
crypto/rsa
github.com/gabriel-vasile/mimetype
crypto/x509/pkix
vendor/golang.org/x/crypto/cryptobyte
vendor/golang.org/x/net/http/httpproxy
github.com/zenazn/goji/graceful/listener
net/textproto
vendor/golang.org/x/net/http/httpguts
mime/multipart
crypto/ecdsa
crypto/x509
crypto/tls
net/http/httptrace
net/http
github.com/GeertJohan/go.rice
github.com/andreimarcu/linx-server/backends
github.com/zenazn/goji/web
github.com/vharitonsky/iniflags
github.com/aws/aws-sdk-go/aws
github.com/andreimarcu/linx-server/httputil
github.com/zenazn/goji/web/mutil
net/http/cgi
github.com/zenazn/goji/graceful
net/http/httputil
github.com/andreimarcu/linx-server/helpers
github.com/andreimarcu/linx-server/backends/localfs
net/http/fcgi
github.com/andreimarcu/linx-server/auth/apikeys
github.com/zenazn/goji/web/middleware
github.com/andreimarcu/linx-server/cleanup
github.com/aws/aws-sdk-go/aws/auth/bearer
github.com/aws/aws-sdk-go/private/protocol/eventstream
github.com/aws/aws-sdk-go/aws/request
github.com/aws/aws-sdk-go/aws/client
github.com/aws/aws-sdk-go/aws/corehandlers
github.com/aws/aws-sdk-go/internal/s3shared/s3err
github.com/aws/aws-sdk-go/internal/s3shared
github.com/aws/aws-sdk-go/private/checksum
github.com/aws/aws-sdk-go/private/protocol
github.com/aws/aws-sdk-go/aws/csm
github.com/aws/aws-sdk-go/aws/ec2metadata
github.com/aws/aws-sdk-go/private/protocol/rest
github.com/aws/aws-sdk-go/private/protocol/query/queryutil
github.com/aws/aws-sdk-go/private/protocol/json/jsonutil
github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil
github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamapi
github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds
github.com/aws/aws-sdk-go/aws/credentials/endpointcreds
github.com/aws/aws-sdk-go/private/protocol/query
github.com/aws/aws-sdk-go/aws/signer/v4
github.com/aws/aws-sdk-go/private/protocol/jsonrpc
github.com/aws/aws-sdk-go/aws/defaults
github.com/aws/aws-sdk-go/private/protocol/restxml
github.com/aws/aws-sdk-go/private/protocol/restjson
github.com/aws/aws-sdk-go/service/sso
github.com/aws/aws-sdk-go/service/ssooidc
github.com/aws/aws-sdk-go/service/sts
github.com/aws/aws-sdk-go/service/s3
github.com/aws/aws-sdk-go/service/sso/ssoiface
github.com/aws/aws-sdk-go/service/sts/stsiface
github.com/aws/aws-sdk-go/aws/credentials/ssocreds
github.com/aws/aws-sdk-go/aws/credentials/stscreds
github.com/aws/aws-sdk-go/aws/session
github.com/aws/aws-sdk-go/service/s3/s3iface
github.com/aws/aws-sdk-go/service/s3/s3manager
github.com/andreimarcu/linx-server/backends/s3
github.com/andreimarcu/linx-server
+ apk del .build-deps
WARNING: opening from cache https://dl-cdn.alpinelinux.org/alpine/v3.20/main: No such file or directory
WARNING: opening from cache https://dl-cdn.alpinelinux.org/alpine/v3.20/community: No such file or directory
(1/13) Purging .build-deps (20241018.074653)
(2/13) Purging git-init-template (2.45.2-r0)
(3/13) Purging git (2.45.2-r0)
(4/13) Purging libcurl (8.10.1-r0)
(5/13) Purging libexpat (2.6.3-r0)
(6/13) Purging libpsl (0.21.5-r1)
(7/13) Purging nghttp2-libs (1.62.1-r0)
(8/13) Purging pcre2 (10.43-r0)
(9/13) Purging zstd-libs (1.5.6-r0)
(10/13) Purging brotli-libs (1.1.0-r2)
(11/13) Purging c-ares (1.33.1-r0)
(12/13) Purging libidn2 (2.3.7-r0)
(13/13) Purging libunistring (1.2-r0)
Executing busybox-1.36.1-r29.trigger
OK: 8 MiB in 15 packages
--> 3244f30e5a8a
[2/2] STEP 1/12: FROM alpine:3.20
[2/2] STEP 2/12: COPY --from=build /go/bin/linx-server /usr/local/bin/linx-server
--> cb5e6362beb7
[2/2] STEP 3/12: ENV GOPATH /go
--> 438133f64faf
[2/2] STEP 4/12: ENV SSL_CERT_FILE /etc/ssl/cert.pem
--> c9bd818b2d46
[2/2] STEP 5/12: COPY static /go/src/github.com/andreimarcu/linx-server/static/
--> 3a43b61b0658
[2/2] STEP 6/12: COPY templates /go/src/github.com/andreimarcu/linx-server/templates/
--> 1224acdd74c7
[2/2] STEP 7/12: RUN mkdir -p /data/files /data/meta /data/locks         && chown -R 65534:65534 /data         && chmod -R u=rwX,go=rX /go/src/github.com/andreimarcu/linx-server
--> ffb66d0aec66
[2/2] STEP 8/12: VOLUME ["/data/files", "/data/meta", "/data/locks"]
--> 2d205e2719da
[2/2] STEP 9/12: EXPOSE 8080
--> 9328ec09ece7
[2/2] STEP 10/12: USER nobody
--> b702e7de419b
[2/2] STEP 11/12: ENTRYPOINT ["/usr/local/bin/linx-server", "-bind=0.0.0.0:8080", "-filespath=/data/files/", "-metapath=/data/meta/", "-lockspath=/data/locks/"]
--> 10468579c91b
[2/2] STEP 12/12: CMD ["-sitename=linx", "-allowhotlink"]
[2/2] COMMIT
--> 8bcf4ca32623
8bcf4ca32623235013f09ae7ba8ea3e33418b071e88b8d8a564cc9058a0159af

@vlnst
Copy link

vlnst commented Oct 18, 2024

I don't get the warning which makes it hard to troubleshoot...

Yeah, my bad, had "dubious ownership in repository" that's why I was getting this error

@vlnst
Copy link

vlnst commented Dec 15, 2024

Latest alpine is 3.21 now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants