Skip to content

Commit

Permalink
Update Dockerfile, set environment CGO_ENABLED=0 to disable dynamic…
Browse files Browse the repository at this point in the history
…ally linked for run in Docker. (#26)
  • Loading branch information
mstmdev committed Jul 4, 2022
1 parent dc6224b commit b793a84
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 15 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ FROM golang:latest AS build
WORKDIR /gowork

ARG GOPROXY
ARG CGO_ENABLED=0

COPY . .

RUN echo $(git rev-parse main) >version/commit

RUN echo $(go version | awk '{print $3 " " $4}') >version/go_version

RUN go build -v -tags netgo -o . ./...
RUN go build -v -o . ./...

FROM alpine:3.15.4

Expand Down
6 changes: 0 additions & 6 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ go install github.com/no-src/gofs/...@latest

### 在Docker中运行

如果你想要在docker中运行,请在安装或者编译的时候使用`-tags netgo`命令行参数或者设置环境变量`CGO_ENABLED=0`,否则当你运行docker容器时可能会报找不到`gofs`的错误

```bash
go install -tags netgo github.com/no-src/gofs/...@latest
```

你可以使用[build-docker.sh](/scripts/build-docker.sh)脚本来构建docker镜像,首先你需要克隆本仓库并且`cd`到本仓库的根目录

```bash
Expand Down
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ go install github.com/no-src/gofs/...@latest

### Run In Docker

If you want to run in a docker, you should install or build with the `-tags netgo` flag or set the
environment `CGO_ENABLED=0`, otherwise you may get an error that the `gofs` not found, when the docker container is
running.

```bash
go install -tags netgo github.com/no-src/gofs/...@latest
```

You can use the [build-docker.sh](/scripts/build-docker.sh) script to build the docker image and you should clone this
repository and `cd` to the root path of the repository first.

Expand Down

0 comments on commit b793a84

Please sign in to comment.