-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This should enable the repo to build the application into an container image.
- Loading branch information
1 parent
65c9084
commit d438e9a
Showing
5 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM docker.io/library/golang:1.22 as builder | ||
#FROM registry.redhat.io/rhel9/go-toolset:1.20 as builder | ||
WORKDIR /opt/app-root/src/ | ||
|
||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
COPY *.go ./ | ||
|
||
RUN CGO_ENABLED=0 go build -o /opt/app-root/webdavserver | ||
RUN mkdir /tmp/webdav | ||
|
||
|
||
FROM scratch | ||
ARG USER=1001 | ||
|
||
COPY --from=builder /opt/app-root/webdavserver /webdavserver | ||
COPY --from=builder --chown=$USER:$USER /tmp/webdav /srv/webdav | ||
|
||
USER $USER:$USER | ||
|
||
CMD ["-webdavDir", "/srv/webdav/"] | ||
ENTRYPOINT ["/webdavserver"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
# webdavserver | ||
# webdavserver | ||
|
||
[![Container Repository on Quay](https://quay.io/repository/dominikholler/webdavserver/status "Container Repository on Quay")](https://quay.io/repository/dominikholler/webdavserver) | ||
|
||
webdavserver is a example application utilizing the webdav server of the golang standard library. | ||
|
||
``` | ||
export WEBDAVDIR=/tmp/webdav | ||
mkdir $WEBDAVDIR | ||
chmod 777 $WEBDAVDIR | ||
podman run --rm -p 8080:8080 -v $WEBDAVDIR:/srv/webdav:z -it quay.io/dominikholler/webdavserver | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/dominikholler/webdavserver | ||
|
||
go 1.20 | ||
|
||
require golang.org/x/net v0.21.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= | ||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"log" | ||
"net/http" | ||
|
||
"golang.org/x/net/webdav" | ||
) | ||
|
||
func logRequest(r *http.Request, err error) { | ||
log.Println(r.RemoteAddr, r.Method, r.URL.Path) | ||
} | ||
|
||
|
||
func main() { | ||
var address, prefix, webdavDir string | ||
|
||
flag.StringVar(&address, "address", "0.0.0.0:8080", "Address to listen to.") | ||
flag.StringVar(&prefix, "prefix", "", "Prefix is the URL path prefix to strip from WebDAV resource paths.") | ||
flag.StringVar(&webdavDir, "webdavDir", ".", "Path to serve") | ||
flag.Parse() | ||
|
||
handler := &webdav.Handler{ | ||
Prefix: prefix, | ||
FileSystem: webdav.Dir(webdavDir), | ||
LockSystem: webdav.NewMemLS(), | ||
Logger: logRequest, | ||
} | ||
|
||
log.Println("serving", webdavDir, "on", address) | ||
http.ListenAndServe(address, handler) | ||
} | ||
|