Skip to content

Commit f04bc01

Browse files
feat: build and push custom images on ghcr registry
- 2 workflows + 1 reusable workflow - 3 customs dockerfiles Signed-off-by: sylvain-pierrot <[email protected]>
1 parent b3bcff2 commit f04bc01

File tree

6 files changed

+257
-0
lines changed

6 files changed

+257
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Build and push action
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
registry:
7+
required: true
8+
type: string
9+
image-name:
10+
required: true
11+
type: string
12+
context:
13+
required: true
14+
type: string
15+
target:
16+
required: true
17+
type: string
18+
file:
19+
required: true
20+
type: string
21+
22+
jobs:
23+
build-and-push:
24+
name: Build and publish image webapp to ghcr.io
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
28+
packages: write
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
## Authenticate to registry repo github
33+
##
34+
- name: Log in to the Container registry
35+
uses: docker/login-action@v3
36+
with:
37+
registry: ${{ inputs.registry }}
38+
username: ${{ github.actor }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
40+
41+
## Build and push Docker image
42+
##
43+
- name: Set up Docker Buildx
44+
uses: docker/setup-buildx-action@v3
45+
46+
- name: Extract metadata (tags, labels) for Docker
47+
id: meta
48+
uses: docker/metadata-action@v5
49+
with:
50+
images: ${{ inputs.registry }}/${{ github.repository }}/${{ inputs.image-name }}
51+
tags: |
52+
type=sha
53+
type=raw,value=latest
54+
55+
- name: Build and push Docker image
56+
uses: docker/build-push-action@v5
57+
with:
58+
context: ${{ inputs.context }}
59+
file: ${{ inputs.context }}/${{ inputs.file }}
60+
target: ${{ inputs.target }}
61+
push: true
62+
tags: ${{ steps.meta.outputs.tags }}
63+
labels: ${{ steps.meta.outputs.labels }}
64+
cache-from: type=registry,ref=${{ inputs.registry }}/${{ github.repository }}/${{ inputs.image-name }}:buildcache
65+
cache-to: type=registry,ref=${{ inputs.registry }}/${{ github.repository }}/${{ inputs.image-name }}:buildcache,mode=max

.github/workflows/ci-kasm-desktop.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: "[CI] Desktop"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- "develop"
8+
paths:
9+
- "images/desktop/**"
10+
11+
jobs:
12+
build-and-push:
13+
name: Build and push action
14+
permissions:
15+
contents: read
16+
packages: write
17+
uses: ./.github/workflows/build-push-action.yml
18+
with:
19+
registry: ghcr.io
20+
image-name: desktop
21+
context: "."
22+
target: ""
23+
file: custom-images/desktop/Dockerfile-kasm-desktop
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: "[CI] Terminal"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- "develop"
8+
paths:
9+
- "images/terminal/**"
10+
11+
jobs:
12+
build-and-push:
13+
name: Build and push action
14+
permissions:
15+
contents: read
16+
packages: write
17+
uses: ./.github/workflows/build-push-action.yml
18+
with:
19+
registry: ghcr.io
20+
image-name: terminal
21+
context: "."
22+
target: ""
23+
file: custom-images/terminal/Dockerfile-kasm-terminal
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
ARG BASE_TAG="develop"
2+
ARG BASE_IMAGE="core-ubuntu-focal"
3+
FROM kasmweb/$BASE_IMAGE:$BASE_TAG
4+
USER root
5+
6+
ENV HOME=/home/kasm-default-profile
7+
ENV STARTUPDIR=/dockerstartup
8+
ENV INST_SCRIPTS=$STARTUPDIR/install
9+
WORKDIR $HOME
10+
11+
######### Customize Container Here ###########
12+
13+
# Add Kasm Branding
14+
RUN cp /usr/share/backgrounds/bg_kasm.png /usr/share/backgrounds/bg_default.png
15+
RUN cp /usr/share/extra/icons/icon_kasm.png /usr/share/extra/icons/icon_default.png
16+
RUN sed -i 's/ubuntu-mono-dark/elementary-xfce/g' $HOME/.config/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml
17+
18+
# Install Utilities
19+
COPY ./src/ubuntu/install/misc $INST_SCRIPTS/misc/
20+
RUN bash $INST_SCRIPTS/misc/install_tools.sh && rm -rf $INST_SCRIPTS/misc/
21+
22+
# Install Google Chrome
23+
COPY ./src/ubuntu/install/chrome $INST_SCRIPTS/chrome/
24+
RUN bash $INST_SCRIPTS/chrome/install_chrome.sh && rm -rf $INST_SCRIPTS/chrome/
25+
26+
# Install Firefox
27+
COPY ./src/ubuntu/install/firefox/ $INST_SCRIPTS/firefox/
28+
COPY ./src/ubuntu/install/firefox/firefox.desktop $HOME/Desktop/
29+
RUN bash $INST_SCRIPTS/firefox/install_firefox.sh && rm -rf $INST_SCRIPTS/firefox/
30+
31+
# Install Custom Certificate Authority
32+
# COPY ./src/ubuntu/install/certificates $INST_SCRIPTS/certificates/
33+
# RUN bash $INST_SCRIPTS/certificates/install_ca_cert.sh && rm -rf $INST_SCRIPTS/certificates/
34+
35+
36+
37+
######### End Customizations ###########
38+
39+
RUN chown 1000:0 $HOME
40+
RUN $STARTUPDIR/set_user_permission.sh $HOME
41+
42+
ENV HOME=/home/kasm-user
43+
WORKDIR $HOME
44+
RUN mkdir -p $HOME && chown -R 1000:0 $HOME
45+
46+
USER 1000
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM kasmweb/desktop:1.15.0
2+
USER root
3+
4+
ENV HOME=/home/kasm-default-profile
5+
ENV STARTUPDIR=/dockerstartup
6+
ENV INST_SCRIPTS=$STARTUPDIR/install
7+
WORKDIR $HOME
8+
9+
######### Customize Container Here ###########
10+
# Install tools
11+
ENV INST_DIR=$STARTUPDIR/install
12+
COPY ./src/ $INST_DIR
13+
RUN bash $INST_SCRIPTS/ubuntu/install/s3cmd/install_s3cmd.sh
14+
15+
# Install Custom Certificate Authority
16+
COPY ./src/ubuntu/install/certificates $INST_SCRIPTS/certificates/
17+
RUN bash $INST_SCRIPTS/certificates/install_ca_cert.sh && rm -rf $INST_SCRIPTS/certificates/
18+
19+
ENV http_proxy=http://proxy.sensimesh.nchc.org.tw:3128
20+
ENV https_proxy=http://proxy.sensimesh.nchc.org.tw:3128
21+
ENV ftp_proxy=http://proxy.sensimesh.nchc.org.tw:3128
22+
ENV no_proxy=.sensimesh.nchc.org.tw
23+
24+
COPY ./proxy.json /etc/opt/chrome/policies/managed/proxy.json
25+
COPY ./policies.json /usr/lib/firefox/distribution/policies.json
26+
27+
######### End Customizations ###########
28+
29+
RUN chown 1000:0 $HOME
30+
RUN $STARTUPDIR/set_user_permission.sh $HOME
31+
32+
ENV HOME=/home/kasm-user
33+
WORKDIR $HOME
34+
RUN mkdir -p $HOME && chown -R 1000:0 $HOME
35+
36+
USER 1000
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
ARG BASE_TAG="develop"
2+
ARG BASE_IMAGE="core-ubuntu-focal"
3+
FROM kasmweb/$BASE_IMAGE:$BASE_TAG
4+
USER root
5+
6+
ENV HOME=/home/kasm-default-profile
7+
ENV STARTUPDIR=/dockerstartup
8+
ENV INST_SCRIPTS=$STARTUPDIR/install
9+
WORKDIR $HOME
10+
11+
######### Customize Container Here ###########
12+
13+
RUN apt-get update && apt-get install -y tmux screen nano dnsutils zip p7zip-full rclone s3cmd wget curl net-tools
14+
15+
RUN echo "set -g mouse on" > $HOME/.tmux.conf && chown 1000:1000 $HOME/.tmux.conf
16+
17+
### Update .bashrc to run an arbitrary command if specified as an environment variable
18+
RUN echo "if [ ! -z \"\${SHELL_EXEC}\" ] && [ \"\${TERM}\" == \"xterm-256color\" ] ; \n\
19+
then \n\
20+
set +e \n\
21+
eval \${SHELL_EXEC} \n\
22+
fi " >> $HOME/.bashrc && chown 1000:1000 $HOME/.bashrc
23+
24+
# Install Custom Certificate Authority
25+
COPY ./src/ubuntu/install/certificates $INST_SCRIPTS/certificates/
26+
RUN bash $INST_SCRIPTS/certificates/install_ca_cert.sh && rm -rf $INST_SCRIPTS/certificates/
27+
28+
COPY ./proxy.json /etc/opt/chrome/policies/managed/proxy.json
29+
COPY ./policies.json /usr/lib/firefox/distribution/policies.json
30+
31+
32+
### Install Ansible
33+
COPY ./src/ubuntu/install/ansible $INST_SCRIPTS/ansible/
34+
RUN bash $INST_SCRIPTS/ansible/install_ansible.sh && rm -rf $INST_SCRIPTS/ansible/
35+
36+
### Install Terraform
37+
COPY ./src/ubuntu/install/terraform $INST_SCRIPTS/terraform/
38+
RUN bash $INST_SCRIPTS/terraform/install_terraform.sh && rm -rf $INST_SCRIPTS/terraform/
39+
40+
COPY ./src/ubuntu/install/terminal/custom_startup.sh $STARTUPDIR/custom_startup.sh
41+
RUN chmod +x $STARTUPDIR/custom_startup.sh
42+
RUN chmod 755 $STARTUPDIR/custom_startup.sh
43+
44+
# Update the desktop environment to be optimized for a single application
45+
RUN cp $HOME/.config/xfce4/xfconf/single-application-xfce-perchannel-xml/* $HOME/.config/xfce4/xfconf/xfce-perchannel-xml/
46+
RUN cp /usr/share/backgrounds/bg_kasm.png /usr/share/backgrounds/bg_default.png
47+
RUN apt-get remove -y xfce4-panel
48+
49+
50+
######### End Customizations ###########
51+
52+
ENV http_proxy=http://proxy.sensimesh.nchc.org.tw:3128
53+
ENV https_proxy=http://proxy.sensimesh.nchc.org.tw:3128
54+
ENV ftp_proxy=http://proxy.sensimesh.nchc.org.tw:3128
55+
ENV no_proxy=.sensimesh.nchc.org.tw
56+
57+
RUN chown 1000:0 $HOME
58+
RUN $STARTUPDIR/set_user_permission.sh $HOME
59+
60+
ENV HOME=/home/kasm-user
61+
WORKDIR $HOME
62+
RUN mkdir -p $HOME && chown -R 1000:0 $HOME
63+
64+
USER 1000

0 commit comments

Comments
 (0)