Skip to content

Commit abb01f2

Browse files
committed
add Containerfile and action to build an push image
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
1 parent d188b64 commit abb01f2

4 files changed

Lines changed: 126 additions & 1 deletion

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build and Push Container Image
2+
3+
on:
4+
push:
5+
paths:
6+
- 'workspace-container-image/Containerfile'
7+
- 'workspace-container-image/entrypoint.sh'
8+
9+
jobs:
10+
build-and-push:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repo
15+
uses: actions/checkout@v4
16+
17+
- name: Set up QEMU
18+
uses: docker/setup-qemu-action@v3
19+
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v3
22+
23+
- name: Log in to Quay.io
24+
uses: docker/login-action@v3
25+
with:
26+
registry: quay.io
27+
username: ${{ secrets.QUAY_USERNAME }}
28+
password: ${{ secrets.QUAY_PASSWORD }}
29+
30+
- name: Generate tag
31+
id: tag
32+
run: echo "tag=$(date +%Y%m%d-%H%M%S)" >> $GITHUB_OUTPUT
33+
34+
- name: Build and push multi-arch image
35+
uses: docker/build-push-action@v5
36+
with:
37+
context: ./workspace-container-image
38+
file: ./workspace-container-image/Containerfile
39+
push: true
40+
tags: quay.io/devspaces/dotnet-90:9.0-fedora-${{ steps.tag.outputs.tag }}
41+
platforms: linux/amd64,linux/ppc64le,linux/s390x

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ The app will print `Hello World!`
1010

1111
## Image Of Devfile
1212

13-
[Community .NET Image](quay.io/cgruver0/che/dot-net:fedora) is used as an image for .NET development and it's defined in https://github.com/cgruver/dev-spaces-dotnet/blob/main/workspace-container-image/Containerfile.
13+
[Community .NET Image](quay.io/devspaces/dotnet-90) is used as an image for .NET development and it's defined in https://github.com/devspaces-samples/dotnet-web-simple/blob/devspaces-3-rhel-9/workspace-container-image/Containerfile.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM quay.io/fedora/fedora:41
2+
3+
ARG USER_HOME_DIR="/home/user"
4+
ARG WORK_DIR="/projects"
5+
ARG INSTALL_PACKAGES="procps-ng openssl git tar gzip zip xz unzip which shadow-utils bash zsh vi wget jq podman buildah skopeo podman-docker glibc-devel zlib-devel gcc libffi-devel libstdc++-devel gcc-c++ glibc-langpack-en ca-certificates python3-pip python3-devel fuse-overlayfs util-linux vim-minimal vim-enhanced dotnet-hostfxr-9.0 dotnet-runtime-9.0 dotnet-sdk-9.0"
6+
7+
ENV HOME=${USER_HOME_DIR}
8+
ENV BUILDAH_ISOLATION=chroot
9+
10+
COPY --chown=0:0 entrypoint.sh /
11+
12+
RUN microdnf --disableplugin=subscription-manager install -y ${INSTALL_PACKAGES}; \
13+
microdnf update -y ; \
14+
microdnf clean all ; \
15+
mkdir -p /usr/local/bin ; \
16+
mkdir -p ${WORK_DIR} ; \
17+
pip3 install -U podman-compose ; \
18+
pip3 install -U cekit ; \
19+
chgrp -R 0 /home ; \
20+
chmod -R g=u /home ${WORK_DIR} ; \
21+
chmod +x /entrypoint.sh ; \
22+
chown 0:0 /etc/passwd ; \
23+
chown 0:0 /etc/group ; \
24+
chmod g=u /etc/passwd /etc/group ; \
25+
# Setup for rootless podman
26+
setcap cap_setuid+ep /usr/bin/newuidmap ; \
27+
setcap cap_setgid+ep /usr/bin/newgidmap ; \
28+
touch /etc/subgid /etc/subuid ; \
29+
chown 0:0 /etc/subgid ; \
30+
chown 0:0 /etc/subuid ; \
31+
chmod -R g=u /etc/subuid /etc/subgid ; \
32+
# Create Sym Links for OpenShift CLI (Assumed to be retrieved by an init-container)
33+
ln -s /projects/bin/oc /usr/local/bin/oc ; \
34+
ln -s /projects/bin/kubectl /usr/local/bin/kubectl
35+
36+
USER 1000
37+
WORKDIR ${WORK_DIR}
38+
ENTRYPOINT ["/usr/libexec/podman/catatonit","--","/entrypoint.sh"]
39+
CMD [ "tail", "-f", "/dev/null" ]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
3+
# Create Home directory
4+
if [ ! -d "${HOME}" ]
5+
then
6+
mkdir -p "${HOME}"
7+
fi
8+
9+
# Configure Podman builds to use vfs or fuse-overlayfs
10+
if [ ! -d "${HOME}/.config/containers" ]; then
11+
mkdir -p ${HOME}/.config/containers
12+
if [ -c "/dev/fuse" ] && [ -f "/usr/bin/fuse-overlayfs" ]; then
13+
(echo '[storage]';echo 'driver = "overlay"';echo '[storage.options.overlay]';echo 'mount_program = "/usr/bin/fuse-overlayfs"') > ${HOME}/.config/containers/storage.conf
14+
else
15+
(echo '[storage]';echo 'driver = "vfs"') > "${HOME}"/.config/containers/storage.conf
16+
fi
17+
fi
18+
19+
# Create User ID
20+
if ! whoami &> /dev/null
21+
then
22+
if [ -w /etc/passwd ]
23+
then
24+
echo "${USER_NAME:-user}:x:$(id -u):0:${USER_NAME:-user} user:${HOME}:/bin/bash" >> /etc/passwd
25+
echo "${USER_NAME:-user}:x:$(id -u):" >> /etc/group
26+
fi
27+
fi
28+
29+
# Create subuid/gid entries for the user
30+
USER=$(whoami)
31+
START_ID=$(( $(id -u)+1 ))
32+
echo "${USER}:${START_ID}:2147483646" > /etc/subuid
33+
echo "${USER}:${START_ID}:2147483646" > /etc/subgid
34+
35+
# Configure Z shell
36+
if [ ! -f ${HOME}/.zshrc ]
37+
then
38+
(echo "HISTFILE=${HOME}/.zsh_history"; echo "HISTSIZE=1000"; echo "SAVEHIST=1000") > ${HOME}/.zshrc
39+
(echo "if [ -f ${PROJECT_SOURCE}/workspace.rc ]"; echo "then"; echo " . ${PROJECT_SOURCE}/workspace.rc"; echo "fi") >> ${HOME}/.zshrc
40+
fi
41+
42+
# Login to the local image registry
43+
podman login -u $(oc whoami) -p $(oc whoami -t) image-registry.openshift-image-registry.svc:5000
44+
45+
exec "$@"

0 commit comments

Comments
 (0)