1
0
Fork 0

Initial commit

pull/2/head
Ambrose Chua 2019-09-26 14:56:53 +08:00
commit 621e0793fd
Signed by: ambrose
GPG Key ID: BC367D33F140B5C2
3 changed files with 105 additions and 0 deletions

47
Dockerfile Normal file
View File

@ -0,0 +1,47 @@
#
# Build stage
#
FROM alpine:3.10 as build
# args
ARG version="master"
# build root
WORKDIR /build
RUN apk add --no-cache git upx ca-certificates alpine-sdk cmake zlib-dev
# source
RUN git clone https://github.com/lpereira/lwan -b ${version} .
# build
RUN mkdir build \
&& cd build \
&& cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXE_LINKER_FLAGS="-static" -DCMAKE_C_FLAGS="-static" \
&& make
# compress and test
#RUN cd build \
# && ls -l src/bin/lwan \
# && upx --ultra-brute src/bin/lwan/lwan
#
# Final image
#
FROM scratch
# labels
LABEL org.label-schema.vcs-url="https://github.com/productionwentdown/lwan"
LABEL org.label-schema.version=${version}
LABEL org.label-schema.schema-version="1.0"
# copy binary and ca certs
COPY --from=build /build/build/src/bin/lwan/lwan /bin/lwan
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
# copy default caddyfile
COPY lwan.conf /etc/lwan.conf
# serve from /srv
WORKDIR /srv
EXPOSE 8080
ENTRYPOINT ["/bin/lwan", "--config", "/etc/lwan.conf"]

23
README.md Normal file
View File

@ -0,0 +1,23 @@
# [lwan](https://hub.docker.com/r/productionwentdown/lwan/) [![](https://images.microbadger.com/badges/version/productionwentdown/lwan.svg)](https://microbadger.com/images/productionwentdown/lwan "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/productionwentdown/lwan.svg)](https://microbadger.com/images/productionwentdown/lwan "Get your own image badge on microbadger.com")
A tiny Lwan Web Server image compressed with [UPX](https://github.com/upx/upx).
> Notice: I keep this manually updated. If it goes out of date, ping me via Twitter [@serverwentdown](https://twitter.com/serverwentdown).
# Usage
Serve files in `$PWD`:
```
docker run -it --rm -p 8080:8080 -v $PWD:/srv productionwentdown/lwan
```
Overwrite `lwan.conf`:
```
docker run -it --rm -p 8080:8080 -v $PWD:/srv -v $PWD/lwan.conf:/etc/lwan.conf productionwentdown/lwan
```
Run as specific user:
```
docker run -it --rm -p 8080:8080 -v $PWD:/srv --user 900 productionwentdown/lwan
```

35
lwan.conf Normal file
View File

@ -0,0 +1,35 @@
# Timeout in seconds to keep a connection alive.
keep_alive_timeout = 15
# Set to true to not print any debugging messages. (Only effective in
# release builds.)
quiet = false
# Set SO_REUSEPORT=1 in the master socket.
reuse_port = false
# Value of "Expires" header. Default is 1 month and 1 week.
expires = 1M 1w
# Number of I/O threads. Default (0) is number of online CPUs.
threads = 0
# Disable HAProxy's PROXY protocol by default. Only enable if needed.
proxy_protocol = false
# Enable straitjacket by default. The `drop_capabilities` option is `true`
# by default. Other options may require more privileges.
straitjacket {
drop_capabilities = false
}
listener *:8080 {
serve_files / {
path = /srv
# When requesting for file.ext, look for a smaller/newer file.ext.gz,
# and serve that instead if `Accept-Encoding: gzip` is in the
# request headers.
serve precompressed files = true
}
}