Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin/
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM golang:1.17-alpine AS Build

COPY . /code
WORKDIR /code

RUN go env -w GO111MODULE="on" \
&& go build -o easyhttpd main.go

FROM alpine:3.14

COPY --from=Build /code/easyhttpd /usr/local/bin/easyhttpd

RUN chmod +x /usr/local/bin/easyhttpd \
&& addgroup www \
&& adduser -D -H -G www http \
&& mkdir -p /srv/www \
&& chown -R http.www /srv/www

USER http

EXPOSE 8008

ENTRYPOINT ["easyhttpd"]
CMD ["-r", "/srv/www"]
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,14 @@ easyhttpd.exe -r ./ -p :8888
- [x] run cmd open
- [x] file read and write
- [x] host ip address
- [x] multi platform cross compilation
- [x] multi platform cross compilation

## Docker镜像

### 构建容器镜像

`docker image build -t <namespace>/easyhttpd:<tag> .`

### 使用容器运行

`docker container run -t -v <local_html_path>:/srv/www -p 8008:8008 <namespace>/easyhttpd:<tag>`