ldap-1-backend/Dockerfile

35 lines
1.2 KiB
Docker
Raw Normal View History

FROM registry.cn-hangzhou.aliyuncs.com/ali_eryajf/golang:1.18.10-alpine3.17 AS builder
2022-06-01 17:16:45 +08:00
WORKDIR /app
2022-06-01 17:16:45 +08:00
2024-04-05 12:01:50 +08:00
ENV GOPROXY https://goproxy.io
RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories \
&& apk upgrade && apk add --no-cache --virtual .build-deps \
ca-certificates gcc g++ curl upx
2023-01-16 18:21:11 +08:00
ADD . .
2023-01-16 18:21:11 +08:00
2024-04-05 12:01:50 +08:00
COPY --from=registry.cn-hangzhou.aliyuncs.com/ali_eryajf/docker-compose-wait /wait .
RUN release_url=$(curl -s https://api.github.com/repos/eryajf/go-ldap-admin-ui/releases/latest | grep "browser_download_url" | grep -v 'dist.zip.md5' | cut -d '"' -f 4); wget $release_url && unzip dist.zip && rm dist.zip && mv dist public/static
2023-01-16 18:21:11 +08:00
RUN sed -i 's@localhost:389@openldap:389@g' /app/config.yml \
2024-04-05 12:01:50 +08:00
&& sed -i 's@host: localhost@host: mysql@g' /app/config.yml && go build -o go-ldap-admin . && upx -9 go-ldap-admin && upx -9 wait
2022-06-01 17:16:45 +08:00
2023-01-16 18:21:11 +08:00
### build final image
FROM registry.cn-hangzhou.aliyuncs.com/ali_eryajf/alpine:3.19
2023-01-16 18:21:11 +08:00
LABEL maintainer eryajf@163.com
2023-01-16 18:21:11 +08:00
2022-06-01 17:16:45 +08:00
WORKDIR /app
2023-01-16 18:21:11 +08:00
COPY --from=builder /app/wait .
COPY --from=builder /app/LICENSE .
COPY --from=builder /app/config.yml .
COPY --from=builder /app/go-ldap-admin .
2023-01-16 18:21:11 +08:00
RUN chmod +x wait go-ldap-admin
2023-05-31 22:18:22 +08:00
# see wait repo: https://github.com/ufoscout/docker-compose-wait
CMD ./wait && ./go-ldap-admin