mirror of
https://github.com/emikulic/darkhttpd.git
synced 2023-08-10 21:13:08 +03:00
Dockerize (#3)
Add static build option to Makefile and create Dockerfile to run it.
This commit is contained in:
parent
9222bbc9d8
commit
35c488b95f
16
Dockerfile
Normal file
16
Dockerfile
Normal file
@ -0,0 +1,16 @@
|
||||
# Build environment
|
||||
FROM alpine AS build
|
||||
RUN apk add --no-cache build-base
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
RUN make darkhttpd-static \
|
||||
&& strip darkhttpd-static
|
||||
|
||||
# Just the static binary
|
||||
FROM scratch
|
||||
WORKDIR /var/www/htdocs
|
||||
COPY --from=build /src/darkhttpd-static /darkhttpd
|
||||
EXPOSE 80
|
||||
ENTRYPOINT ["/darkhttpd"]
|
||||
CMD ["."]
|
||||
|
5
Makefile
5
Makefile
@ -7,7 +7,10 @@ all: darkhttpd
|
||||
darkhttpd: darkhttpd.c
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) darkhttpd.c -o $@
|
||||
|
||||
darkhttpd-static: darkhttpd.c
|
||||
$(CC) -static $(CFLAGS) $(LDFLAGS) $(LIBS) darkhttpd.c -o $@
|
||||
|
||||
clean:
|
||||
rm -f darkhttpd core darkhttpd.core
|
||||
rm -f darkhttpd core darkhttpd.core darkhttpd-static darkhttpd-static.core
|
||||
|
||||
.PHONY: all clean
|
||||
|
14
README.md
14
README.md
@ -24,6 +24,7 @@ Features:
|
||||
* At some point worked on FreeBSD, Linux, OpenBSD, Solaris.
|
||||
* ISC license.
|
||||
* suckless.org says [darkhttpd sucks less](http://suckless.org/rocks/).
|
||||
* Small Docker image (<100KB)
|
||||
|
||||
Security:
|
||||
* Can log accesses, including Referer and User-Agent.
|
||||
@ -142,4 +143,17 @@ run darkhttpd without any arguments:
|
||||
./darkhttpd
|
||||
```
|
||||
|
||||
## How to run darkhttpd in Docker
|
||||
|
||||
First, build the image.
|
||||
```
|
||||
docker build -t darkhttpd .
|
||||
```
|
||||
Then run using volumes for the served files and port mapping for access.
|
||||
|
||||
For example, the following would serve files from the current user's dev/mywebsite directory on http://localhost:8080/
|
||||
```
|
||||
docker run -p 8080:80 -v ~/dev/mywebsite:/var/www/htdocs:ro darkhttpd
|
||||
```
|
||||
|
||||
Enjoy.
|
||||
|
Loading…
Reference in New Issue
Block a user