Skip to content

Commit 23711ef

Browse files
committed
Fix Dockerfile
Change-Id: Ia9b5d3739f6a95a1e633a433cf4bedc4948a7619
1 parent ece72cb commit 23711ef

File tree

3 files changed

+33
-15
lines changed

3 files changed

+33
-15
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
*
22
!templates/main.html
3+
!i18n
34
!go.mod
45
!go.sum
6+
!testdata
57
!service.go
68
!service_test.go
79
!LICENSE

Changes

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
0.1.4 2024-03-15
2+
- Update dependencies
3+
- Fix docker image
4+
15
0.1.3 2023-10-10
26
- Update dependencies
3-
- Release to Zenodo.
7+
- Release to Zenodo
48

59
0.1.2 2023-09-05
610
- Log server port

Dockerfile

+26-14
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,49 @@
11
# Build stage
22
FROM golang:latest as build
3+
4+
RUN apt-get update && \
5+
apt-get upgrade -y ca-certificates
6+
37
WORKDIR /src
48

59
COPY go.mod go.sum ./
610
RUN go mod download
711

812
COPY . /src
913

10-
RUN apt-get update && \
11-
apt-get upgrade -y ca-certificates
14+
RUN CGO_ENABLED=0 go test .
1215

13-
RUN go test .
16+
# Build static
17+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
18+
go build -v \
19+
-ldflags "-extldflags '-static' -s -w" \
20+
--trimpath \
21+
-o /src/external-big .
1422

15-
RUN STATIC="-extldflags '-static'" \
16-
STATICENV="CGO_ENABLED=0 GOOS=linux GOARCH=amd64" \
17-
go build -o /src/kalamar-plugin-externalresources .
23+
FROM gruebel/upx:latest as upx
1824

19-
# Main stage
20-
FROM busybox:glibc
25+
COPY --from=build /src/external-big /external-big
2126

22-
EXPOSE 5722
27+
# Compress the binary and copy it to final image
28+
RUN upx --best --lzma -o /external /external-big
29+
30+
# Main stage
31+
FROM scratch AS final
2332

2433
WORKDIR /
2534

35+
EXPOSE 5722
36+
2637
COPY --from=build /etc/ssl/certs /etc/ssl/certs
27-
COPY --from=build /src/kalamar-plugin-externalresources /kalamar-plugin-externalresources
2838
COPY --from=build /src/templates /templates
39+
COPY --from=build /src/i18n /i18n
40+
COPY --from=upx /external /external
2941

30-
ENTRYPOINT [ "./kalamar-plugin-externalresources" ]
42+
ENTRYPOINT [ "/external" ]
3143

3244
LABEL maintainer="korap@ids-mannheim.de"
3345
LABEL description="Docker Image for Kalamar-Plugin-ExternalResources, a frontend plugin to link texts to external resources"
34-
LABEL repository="https://github.com/KorAP/..."
46+
LABEL repository="https://github.com/KorAP/Kalamar-Plugin-ExternalResources"
3547

36-
# docker build -f Dockerfile -t korap/kalamar-plugin-externalresources .
37-
# docker run --rm --network host -v ${PWD}/db/:/db/:z -v ${PWD}/.env:/.env korap/kalamar-plugin-externalresources
48+
# docker build -f Dockerfile -t korap/kalamar-plugin-externalresources:latest .
49+
# docker run --rm --network host -v ${PWD}/db/:/db/:z -v ${PWD}/.env:/.env korap/kalamar-plugin-externalresources:latest

0 commit comments

Comments
 (0)