perf(forgejo): optimise docker build
- Mount the context directory to the build container to copy files over to their destinations. - Add .dockerignore to minimize the context.
This commit is contained in:
parent
e2e8424d1a
commit
b961753dd2
2 changed files with 21 additions and 15 deletions
5
templates/forgejo/.dockerignore.gotmpl
Normal file
5
templates/forgejo/.dockerignore.gotmpl
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
*
|
||||||
|
!app.ini
|
||||||
|
!dynamic_git.yaml
|
||||||
|
!entrypoint.sh
|
||||||
|
!forgejo-{{ .Forgejo.Version }}-linux-amd64
|
|
@ -11,7 +11,8 @@ ENV FORGEJO_WORK_DIR={{ .Forgejo.Work }} \
|
||||||
FORGEJO_VERSION={{ .Forgejo.Version }} \
|
FORGEJO_VERSION={{ .Forgejo.Version }} \
|
||||||
HOME={{ .Forgejo.Home }}
|
HOME={{ .Forgejo.Home }}
|
||||||
|
|
||||||
RUN apk update && apk upgrade && apk --no-cache add \
|
RUN --mount=type=bind,source=.,target=/packages \
|
||||||
|
apk update && apk upgrade && apk --no-cache add \
|
||||||
asciidoctor \
|
asciidoctor \
|
||||||
bash \
|
bash \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
|
@ -21,26 +22,26 @@ RUN apk update && apk upgrade && apk --no-cache add \
|
||||||
gnupg \
|
gnupg \
|
||||||
&& addgroup -S -g {{ .FlowGID }} flow \
|
&& addgroup -S -g {{ .FlowGID }} flow \
|
||||||
&& adduser -S -H -D -h {{ .Forgejo.Home }} -s /bin/bash -u {{ .Forgejo.LinuxUID }} -G flow git \
|
&& adduser -S -H -D -h {{ .Forgejo.Home }} -s /bin/bash -u {{ .Forgejo.LinuxUID }} -G flow git \
|
||||||
&& mkdir -p {{ .Forgejo.DataContainerDirectory }} {{ .Forgejo.Tmp }} \
|
&& mkdir -p {{ .Forgejo.DataContainerDirectory }} {{ .Forgejo.Tmp }} /flow/gitea/config \
|
||||||
&& chown git {{ .Forgejo.DataContainerDirectory }} && chmod 0700 {{ .Forgejo.DataContainerDirectory }} \
|
&& chown git {{ .Forgejo.DataContainerDirectory }} && chmod 0700 {{ .Forgejo.DataContainerDirectory }} \
|
||||||
&& chown git {{ .Forgejo.Tmp }} && chmod 0700 {{ .Forgejo.Tmp }}
|
&& chown git {{ .Forgejo.Tmp }} && chmod 0700 {{ .Forgejo.Tmp }} \
|
||||||
|
&& chown git /flow/gitea/config && chmod 0700 /flow/gitea/config \
|
||||||
ADD --chown=root:root forgejo-{{ .Forgejo.Version }}-linux-amd64 {{ .Forgejo.Bin }}
|
&& cp /packages/forgejo-{{ .Forgejo.Version }}-linux-amd64 {{ .Forgejo.Bin }} \
|
||||||
ADD app.ini {{ .Forgejo.AppIni }}
|
|
||||||
ADD entrypoint.sh /usr/local/bin/entrypoint.sh
|
|
||||||
ADD --chown={{ .Forgejo.LinuxUID }}:{{ .FlowGID }} dynamic_git.yaml {{ .Forgejo.Tmp }}/
|
|
||||||
|
|
||||||
RUN chown -R {{ .Forgejo.LinuxUID }}:{{ .Forgejo.LinuxUID }} {{ .Forgejo.AppIni }} \
|
|
||||||
&& chmod 0400 {{ .Forgejo.AppIni }} \
|
|
||||||
&& chmod a+x {{ .Forgejo.Bin }} \
|
&& chmod a+x {{ .Forgejo.Bin }} \
|
||||||
&& chmod a+rx /usr/local/bin/entrypoint.sh
|
&& cp /packages/app.ini {{ .Forgejo.AppIni }} \
|
||||||
|
&& chown {{ .Forgejo.LinuxUID }}:{{ .Forgejo.LinuxUID }} {{ .Forgejo.AppIni }} \
|
||||||
|
&& chmod 0400 {{ .Forgejo.AppIni }} \
|
||||||
|
&& cp /packages/entrypoint.sh /usr/local/bin/entrypoint \
|
||||||
|
&& chmod a+rx /usr/local/bin/entrypoint \
|
||||||
|
&& cp /packages/dynamic_git.yaml {{ .Forgejo.Tmp }}/dynamic_git.yaml \
|
||||||
|
&& chown {{ .Forgejo.LinuxUID }}:{{ .FlowGID }} {{ .Forgejo.Tmp }}/dynamic_git.yaml
|
||||||
|
|
||||||
USER {{ .Forgejo.LinuxUID }}:{{ .FlowGID }}
|
USER {{ .Forgejo.LinuxUID }}:{{ .FlowGID }}
|
||||||
|
|
||||||
WORKDIR /flow/gitea/data
|
WORKDIR {{ .Forgejo.Home }}
|
||||||
|
|
||||||
VOLUME ["/flow/gitea/data"]
|
VOLUME ["{{ .Forgejo.DataContainerDirectory }}"]
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
ENTRYPOINT ["entrypoint"]
|
||||||
|
|
||||||
CMD []
|
CMD []
|
||||||
|
|
Loading…
Reference in a new issue