-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
100 lines (86 loc) · 3.52 KB
/
Copy pathDockerfile
File metadata and controls
100 lines (86 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# syntax=docker/dockerfile:1
ARG FEDORA_VERSION=44
FROM registry.fedoraproject.org/fedora:${FEDORA_VERSION} AS dotfiles-test
ARG TARGETPLATFORM
ARG TEST_USER=dotfiles
ARG TEST_UID=1000
ARG TEST_GID=${TEST_UID}
ARG TEST_HOME=/home/dotfiles
# Keep this smoke-test Dockerfile on Podman/Buildah-compatible syntax. GitHub
# Actions installs Podman from Ubuntu apt, whose imagebuilder rejects BuildKit
# conveniences like COPY --link and heredoc RUN blocks.
COPY containers/fedora-smoke-test-packages.txt /tmp/fedora-smoke-test-packages.txt
RUN --mount=type=cache,id=dotfiles-dnf4-${TARGETPLATFORM},sharing=locked,target=/var/cache/dnf \
--mount=type=cache,id=dotfiles-dnf5-${TARGETPLATFORM},sharing=locked,target=/var/cache/libdnf5 \
set -eu; \
dnf install -y --setopt=install_weak_deps=False $(sed '/^[[:space:]]*#/d; /^[[:space:]]*$/d' /tmp/fedora-smoke-test-packages.txt)
RUN set -eu; \
mkdir -p "$(dirname "${TEST_HOME}")"; \
groupadd --gid "${TEST_GID}" "${TEST_USER}"; \
useradd --uid "${TEST_UID}" --gid "${TEST_GID}" --create-home --home-dir "${TEST_HOME}" "${TEST_USER}"; \
chown -R "${TEST_UID}:${TEST_GID}" "${TEST_HOME}"
USER ${TEST_USER}
ENV HOME=${TEST_HOME}
ENV XDG_CACHE_HOME=${TEST_HOME}/.cache
ENV TMPDIR=${TEST_HOME}/.cache/tmp
ENV TMP=${TEST_HOME}/.cache/tmp
ENV TEMP=${TEST_HOME}/.cache/tmp
ENV PATH=${TEST_HOME}/.local/bin:${TEST_HOME}/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV DOTFILES_PROCESS_CAPTURE_TIMEOUT_SECS=180
ENV GOTOOLCHAIN=auto
ENV GOCACHE=${TEST_HOME}/.cache/go-build
ENV GOMODCACHE=${TEST_HOME}/go/pkg/mod
RUN mkdir -p "${TMPDIR}" "${GOCACHE}" "${GOMODCACHE}" "${HOME}/.local/bin"
WORKDIR /workspace/dotfiles
COPY --chown=${TEST_USER}:${TEST_USER} go.mod go.sum ./
RUN --mount=type=cache,id=dotfiles-go-mod-${TARGETPLATFORM},target=/home/dotfiles/go/pkg/mod,uid=${TEST_UID},gid=${TEST_GID} \
go mod download
COPY --chown=${TEST_USER}:${TEST_USER} . .
USER root
RUN chown -R "${TEST_UID}:${TEST_GID}" "${TEST_HOME}" /workspace/dotfiles
USER ${TEST_USER}
RUN --mount=type=cache,id=dotfiles-go-mod-${TARGETPLATFORM},target=/home/dotfiles/go/pkg/mod,uid=${TEST_UID},gid=${TEST_GID} \
--mount=type=cache,id=dotfiles-go-build-${TARGETPLATFORM},target=/home/dotfiles/.cache/go-build,uid=${TEST_UID},gid=${TEST_GID} \
set -eu; \
ansible-galaxy collection install -r ansible/requirements.yml -p .ansible/collections; \
for playbook in ansible/playbooks/bootstrap.yml ansible/playbooks/userland.yml ansible/playbooks/host.yml ansible/playbooks/site.yml; do \
ansible-playbook --syntax-check "${playbook}"; \
done; \
ansible-playbook ansible/playbooks/site.yml --tags local; \
ansible-lint ansible; \
yamllint .
USER root
RUN chown -R "${TEST_UID}:${TEST_GID}" "${TEST_HOME}" /workspace/dotfiles
USER ${TEST_USER}
RUN set -eu; \
chezmoi_targets=" \
.zshrc \
.bashrc \
.gitconfig \
.gitignore_global \
.ssh/config \
.ssh/allowed_signers \
.codex \
.cache/starship \
.cache/zellij \
.config \
.local/bin \
.local/share/applications \
.local/share/zellij \
"; \
set --; \
for target in ${chezmoi_targets}; do \
set -- "$@" "${HOME}/${target}"; \
done; \
chezmoi \
--source=/workspace/dotfiles/dotfiles \
--destination="${HOME}" \
apply \
--force \
--no-tty \
--parent-dirs \
--exclude=scripts \
"$@"
RUN ansible-playbook --version >/dev/null
RUN ansible-lint --version >/dev/null
RUN yamllint --version >/dev/null