Skip to content

Commit 2cf4833

Browse files
committed
fix some issues with building alpine docker images
1 parent f81c34c commit 2cf4833

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

Dockerfile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@ WORKDIR /src
33
COPY go.mod go.sum ./
44
RUN go mod download
55
RUN go install github.com/google/wire/cmd/wire@latest
6-
RUN apk update
7-
RUN apk add --no-cache make
6+
ARG APK_MIRROR
7+
RUN if [ -n "$APK_MIRROR" ]; then \
8+
sed -i "s|https://dl-cdn.alpinelinux.org/alpine|$APK_MIRROR|g" /etc/apk/repositories; \
9+
fi
10+
RUN apk update && apk add --no-cache make gcc musl-dev
811
COPY . .
9-
RUN make
12+
RUN CGO_ENABLED=1 make
1013

1114
FROM alpine
15+
ARG APK_MIRROR
16+
RUN if [ -n "$APK_MIRROR" ]; then \
17+
sed -i "s|https://dl-cdn.alpinelinux.org/alpine|$APK_MIRROR|g" /etc/apk/repositories; \
18+
fi
19+
RUN apk update && apk add --no-cache musl
1220
COPY --from=build /src/csdmpro /usr/local/bin/
1321
RUN mkdir /csdmpro
1422
WORKDIR /csdmpro

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
CGO_ENABLED ?= 0
2+
CC ?= gcc
13
GO_FILES = $(shell find core -type f -name '*.go') \
24
$(shell find tg -type f -name '*.go') \
35
$(shell find db -type f -name '*.go') \
@@ -11,7 +13,7 @@ wire: $(GO_FILES) $(DEV_GO_FILES)
1113
wire
1214

1315
build: $(GO_FILES) $(DEV_GO_FILES) wire
14-
go build
16+
CGO_ENABLED=$(CGO_ENABLED) CC=$(CC) go build
1517

1618
build_watch: $(GO_FILES)
1719
printf "%s\n" $(GO_FILES) $(DEV_GO_FILES) | \

0 commit comments

Comments
 (0)