mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2025-12-23 22:29:59 -05:00
Dockerfile cleanup (#1352)
* Dockerfile.multiarch: use bind- and cache-mounts to speedup build Use a cache mount for go build cache in the build container and mount the sources as a bind mount as recommended in https://docs.docker.com/build/cache/optimize/ this largely speeds up the container build for subsequent builds. * Use Dockerfile.multiarch for "dev-docker" target Let's remove some redundancy. AFAICS the Docker.multiarch does everything the Docker.linux.* files did. And with the build caches enable it should be just as quick as building on the host. * Dockerfile.multiarch: Align the alpine version of the base images * Dockerfile: Reduce build context by adding more files to .dockerignore
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
.bingo
|
||||
!.bingo/*.mod
|
||||
!.bingo/Variables.mk
|
||||
.git
|
||||
**/bin
|
||||
docs
|
||||
**/node_modules
|
||||
**/tmp
|
||||
docs
|
||||
|
||||
@@ -17,8 +17,7 @@ include ../.make/docs.mk
|
||||
|
||||
.PHONY: dev-docker
|
||||
dev-docker:
|
||||
$(MAKE) --no-print-directory release-linux-docker-$(GOARCH)
|
||||
docker build -f docker/Dockerfile.linux.$(GOARCH) -t opencloudeu/opencloud:dev .
|
||||
docker build -f docker/Dockerfile.multiarch -t opencloudeu/opencloud:dev ..
|
||||
|
||||
.PHONY: dev-docker-multiarch
|
||||
dev-docker-multiarch:
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
FROM amd64/alpine:3.21
|
||||
|
||||
ARG VERSION=""
|
||||
ARG REVISION=""
|
||||
|
||||
RUN apk add --no-cache attr bash ca-certificates curl inotify-tools libc6-compat mailcap tree vips patch && \
|
||||
echo 'hosts: files dns' >| /etc/nsswitch.conf
|
||||
|
||||
LABEL maintainer="openCloud GmbH <devops@opencloud.eu>" \
|
||||
org.opencontainers.image.title="OpenCloud" \
|
||||
org.opencontainers.image.vendor="OpenCloud GmbH" \
|
||||
org.opencontainers.image.authors="OpenCloud GmbH" \
|
||||
org.opencontainers.image.description="OpenCloud is a modern file-sync and share platform" \
|
||||
org.opencontainers.image.licenses="Apache-2.0" \
|
||||
org.opencontainers.image.documentation="https://github.com/opencloud-eu/opencloud" \
|
||||
org.opencontainers.image.url="https://hub.docker.com/r/opencloud-eu/opencloud" \
|
||||
org.opencontainers.image.source="https://github.com/opencloud-eu/opencloud" \
|
||||
org.opencontainers.image.version="${VERSION}" \
|
||||
org.opencontainers.image.revision="${REVISION}"
|
||||
|
||||
RUN addgroup -g 1000 -S opencloud-group && \
|
||||
adduser -S --ingroup opencloud-group --uid 1000 opencloud-user --home /var/lib/opencloud
|
||||
|
||||
RUN mkdir -p /var/lib/opencloud && \
|
||||
# Pre-create the web directory to avoid permission issues
|
||||
mkdir -p /var/lib/opencloud/web/assets/apps && \
|
||||
chown -R opencloud-user:opencloud-group /var/lib/opencloud && \
|
||||
chmod -R 751 /var/lib/opencloud && \
|
||||
mkdir -p /etc/opencloud && \
|
||||
chown -R opencloud-user:opencloud-group /etc/opencloud && \
|
||||
chmod -R 751 /etc/opencloud
|
||||
|
||||
VOLUME [ "/var/lib/opencloud", "/etc/opencloud" ]
|
||||
WORKDIR /var/lib/opencloud
|
||||
|
||||
USER 1000
|
||||
|
||||
EXPOSE 9200/tcp
|
||||
|
||||
ENTRYPOINT ["/usr/bin/opencloud"]
|
||||
CMD ["server"]
|
||||
|
||||
COPY dist/binaries/opencloud-linux-amd64 /usr/bin/opencloud
|
||||
@@ -1,43 +0,0 @@
|
||||
FROM arm64v8/alpine:3.21
|
||||
|
||||
ARG VERSION=""
|
||||
ARG REVISION=""
|
||||
|
||||
RUN apk add --no-cache attr bash ca-certificates curl inotify-tools libc6-compat mailcap tree vips patch && \
|
||||
echo 'hosts: files dns' >| /etc/nsswitch.conf
|
||||
|
||||
LABEL maintainer="openCloud GmbH <devops@opencloud.eu>" \
|
||||
org.opencontainers.image.title="OpenCloud" \
|
||||
org.opencontainers.image.vendor="OpenCloud GmbH" \
|
||||
org.opencontainers.image.authors="OpenCloud GmbH" \
|
||||
org.opencontainers.image.description="OpenCloud a modern file-sync and share platform" \
|
||||
org.opencontainers.image.licenses="Apache-2.0" \
|
||||
org.opencontainers.image.documentation="https://github.com/opencloud-eu/opencloud" \
|
||||
org.opencontainers.image.url="https://hub.docker.com/r/opencloud-eu/opencloud" \
|
||||
org.opencontainers.image.source="https://github.com/opencloud-eu/opencloud" \
|
||||
org.opencontainers.image.version="${VERSION}" \
|
||||
org.opencontainers.image.revision="${REVISION}"
|
||||
|
||||
RUN addgroup -g 1000 -S opencloud-group && \
|
||||
adduser -S --ingroup opencloud-group --uid 1000 opencloud-user --home /var/lib/opencloud
|
||||
|
||||
RUN mkdir -p /var/lib/opencloud && \
|
||||
# Pre-create the web directory to avoid permission issues
|
||||
mkdir -p /var/lib/opencloud/web/assets/apps && \
|
||||
chown -R opencloud-user:opencloud-group /var/lib/opencloud && \
|
||||
chmod -R 751 /var/lib/opencloud && \
|
||||
mkdir -p /etc/opencloud && \
|
||||
chown -R opencloud-user:opencloud-group /etc/opencloud && \
|
||||
chmod -R 751 /etc/opencloud
|
||||
|
||||
VOLUME [ "/var/lib/opencloud", "/etc/opencloud" ]
|
||||
WORKDIR /var/lib/opencloud
|
||||
|
||||
USER 1000
|
||||
|
||||
EXPOSE 9200/tcp
|
||||
|
||||
ENTRYPOINT ["/usr/bin/opencloud"]
|
||||
CMD ["server"]
|
||||
|
||||
COPY dist/binaries/opencloud-linux-arm64 /usr/bin/opencloud
|
||||
@@ -6,13 +6,14 @@ ARG STRING
|
||||
|
||||
RUN apk add bash make git curl gcc musl-dev libc-dev binutils-gold inotify-tools vips-dev
|
||||
|
||||
COPY ../ /opencloud/
|
||||
|
||||
WORKDIR /opencloud
|
||||
RUN GOOS="${TARGETOS:-linux}" GOARCH="${TARGETARCH:-amd64}" ; \
|
||||
make -C opencloud release-linux-docker-${TARGETARCH} ENABLE_VIPS=true
|
||||
RUN --mount=type=bind,target=/opencloud \
|
||||
--mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache \
|
||||
GOOS="${TARGETOS:-linux}" GOARCH="${TARGETARCH:-amd64}" ; \
|
||||
make -C opencloud release-linux-docker-${TARGETARCH} ENABLE_VIPS=true DIST=/dist
|
||||
|
||||
FROM alpine:3.20
|
||||
FROM alpine:3.21
|
||||
ARG VERSION
|
||||
ARG REVISION
|
||||
ARG TARGETOS
|
||||
@@ -55,4 +56,4 @@ EXPOSE 9200/tcp
|
||||
ENTRYPOINT ["/usr/bin/opencloud"]
|
||||
CMD ["server"]
|
||||
|
||||
COPY --from=build /opencloud/opencloud/dist/binaries/opencloud-linux-${TARGETARCH} /usr/bin/opencloud
|
||||
COPY --from=build /dist/binaries/opencloud-linux-${TARGETARCH} /usr/bin/opencloud
|
||||
|
||||
Reference in New Issue
Block a user