Skip to content

Commit 1ab2d67

Browse files
committed
Add admin password
1 parent a50dd9b commit 1ab2d67

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

.github/workflows/build-container-bootc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
- name: Run podman build - base
1717
run: |
1818
podman build -t ghcr.io/gbraad-homelab/forgejo/bootc:latest \
19+
--build-arg=ADMIN_PASSWD="password" \
1920
--build-arg=BASE_IMAGE="ghcr.io/gbraad-homelab/private-base/bootc" \
2021
--build-arg=BASE_VERSION="latest" \
2122
-f containers/Containerfile .

.github/workflows/build-container.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ jobs:
1414
- name: Check out repository code
1515
uses: actions/checkout@v4
1616
- name: Run podman build - base
17-
run: podman build -t ghcr.io/gbraad-homelab/forgejo:latest -f containers/Containerfile .
17+
run: |
18+
podman build -t ghcr.io/gbraad-homelab/forgejo:latest \
19+
--build-arg=ADMIN_PASSWD="password" \
20+
-f containers/Containerfile .
1821
- name: Push image to ghcr.io - base
19-
run: podman push --creds=${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} ghcr.io/gbraad-homelab/forgejo:latest
22+
run: |
23+
podman push --creds=${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} \
24+
ghcr.io/gbraad-homelab/forgejo:latest

containers/Containerfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ ARG BASE_VERSION="latest"
33

44
FROM ${BASE_IMAGE}:${BASE_VERSION}
55

6+
# Create a default 'admin' user with the specified password.
7+
# Add it to the 'wheel' group to allow for running sudo commands.
8+
ARG ADMIN_PASSWD
9+
# hadolint ignore=DL4006
10+
RUN if [ -z "${ADMIN_PASSWD}" ] ; then \
11+
echo "ADMIN_PASSWD is a mandatory build argument" && exit 1 ; \
12+
fi \
13+
&& useradd -m -d /var/home/admin -G wheel admin \
14+
&& echo "admin:${ADMIN_PASSWD}" | chpasswd
15+
616
RUN dnf install -y git git-lfs openssh-server \
717
&& dnf clean all \
818
&& rm -rf /var/cache/yum \
@@ -12,9 +22,8 @@ RUN dnf install -y git git-lfs openssh-server \
1222
&& sed -i 's/HOME=\/home\/git/HOME=\/var\/home\/git/' /etc/systemd/system/forgejo.service \
1323
&& systemctl enable forgejo.service \
1424
&& systemctl enable sshd.service \
15-
&& chmod 640 /etc/shadow
16-
17-
RUN mkdir -p /var/home/ \
25+
&& chmod 640 /etc/shadow \
26+
&& mkdir -p /var/home/ \
1827
&& groupadd --system git \
1928
&& useradd --system --shell /bin/bash --comment 'Git Version Control' --gid git --home-dir /var/home/git --create-home git \
2029
&& mkdir /var/lib/forgejo \

0 commit comments

Comments
 (0)