Skip to content

Commit 32c8b91

Browse files
committed
ci: docker build example
1 parent 6bab526 commit 32c8b91

File tree

8 files changed

+368
-17
lines changed

8 files changed

+368
-17
lines changed

.github/workflows/build.yaml

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,60 @@ jobs:
5050
- name: Checkout
5151
uses: actions/checkout@v4
5252

53+
### Comment start - when not using docker build actions
54+
- name: Set up QEMU
55+
uses: docker/setup-qemu-action@v3
56+
57+
- name: Set up Docker Buildx
58+
uses: docker/setup-buildx-action@v3
59+
### Comment end - when not using docker build actions
60+
61+
- name: Login to GitHub Container Registry
62+
uses: docker/login-action@v2
63+
with:
64+
registry: ${{ inputs.registry || env.REGISTRY }}
65+
username: ${{ inputs.registry-user || github.actor }}
66+
password: ${{ secrets.REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}
67+
5368
- name: Source Build Env
5469
id: source-build-env
5570
run: |
5671
cat ./ci/build.env >> $GITHUB_ENV
5772
echo "VERSION=$(cat ./ci/version.txt)" >> $GITHUB_ENV
5873
echo "APPS_JSON_BASE64=$(base64 -w 0 ./ci/apps.json)" >> $GITHUB_ENV
5974
60-
- name: Login to GitHub Container Registry
61-
uses: docker/login-action@v2
75+
### Using Kaniko (https://github.com/GoogleContainerTools/kaniko)
76+
# - uses: int128/kaniko-action@v1
77+
# with:
78+
# push: true
79+
# cache: true
80+
# kaniko-args: |
81+
# --build-arg=FRAPPE_PATH=${{ inputs.frappe-repo || env.FRAPPE_REPO }}
82+
# --build-arg=FRAPPE_BRANCH=${{ inputs.frappe-version || env.FRAPPE_VERSION }}
83+
# --build-arg=PYTHON_VERSION=${{ inputs.py-version || env.PY_VERSION }}
84+
# --build-arg=NODE_VERSION=${{ inputs.nodejs-version || env.NODEJS_VERSION }}
85+
# --build-arg=APPS_JSON_BASE64=${{ inputs.apps-json-base64 || env.APPS_JSON_BASE64 }}
86+
# --context=${{ inputs.context || env.CONTEXT }}
87+
# --destination=ghcr.io/${{ github.repository }}/${{ inputs.image || env.IMAGE }}:${{ inputs.version || env.VERSION }}
88+
# --destination=ghcr.io/${{ github.repository }}/${{ inputs.image || env.IMAGE }}:latest
89+
# file: ${{ inputs.dockerfile || env.DOCKERFILE }}
90+
91+
### Using docker build
92+
- uses: actions/checkout@v4
6293
with:
63-
registry: ${{ inputs.registry || env.REGISTRY }}
64-
username: ${{ inputs.registry-user || github.actor }}
65-
password: ${{ secrets.REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}
94+
repository: frappe/frappe_docker
95+
path: builds
6696

67-
- uses: int128/kaniko-action@v1
97+
- name: Build and push
98+
uses: docker/build-push-action@v5
6899
with:
69100
push: true
70-
cache: true
71-
kaniko-args: |
72-
--build-arg=FRAPPE_PATH=${{ inputs.frappe-repo || env.FRAPPE_REPO }}
73-
--build-arg=FRAPPE_BRANCH=${{ inputs.frappe-version || env.FRAPPE_VERSION }}
74-
--build-arg=PYTHON_VERSION=${{ inputs.py-version || env.PY_VERSION }}
75-
--build-arg=NODE_VERSION=${{ inputs.nodejs-version || env.NODEJS_VERSION }}
76-
--build-arg=APPS_JSON_BASE64=${{ inputs.apps-json-base64 || env.APPS_JSON_BASE64 }}
77-
--context=${{ inputs.context || env.CONTEXT }}
78-
--destination=ghcr.io/${{ github.repository }}/${{ inputs.image || env.IMAGE }}:${{ inputs.version || env.VERSION }}
79-
--destination=ghcr.io/${{ github.repository }}/${{ inputs.image || env.IMAGE }}:latest
80-
file: ${{ inputs.dockerfile || env.DOCKERFILE }}
101+
context: builds
102+
file: builds/${{ inputs.dockerfile || env.DOCKERFILE }}
103+
tags: ghcr.io/${{ github.repository }}/${{ inputs.image || env.IMAGE }}:${{ inputs.version || env.VERSION }},ghcr.io/${{ github.repository }}/${{ inputs.image || env.IMAGE }}:latest
104+
build-args: |
105+
"FRAPPE_PATH=${{ inputs.frappe-repo || env.FRAPPE_REPO }}"
106+
"FRAPPE_BRANCH=${{ inputs.frappe-version || env.FRAPPE_VERSION }}"
107+
"PYTHON_VERSION=${{ inputs.py-version || env.PY_VERSION }}"
108+
"NODE_VERSION=${{ inputs.nodejs-version || env.NODEJS_VERSION }}"
109+
"APPS_JSON_BASE64=${{ inputs.apps-json-base64 || env.APPS_JSON_BASE64 }}"

docs/docker-swarm.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ usermod -aG docker ubuntu
3838
su - ubuntu
3939
```
4040

41+
Clone this repo
42+
43+
```shell
44+
git clone https://github.com/castlecraft/custom_containers
45+
cd custom_containers
46+
```
47+
48+
Note: traefik and portainer yamls specified in the further commands are in `compose` directory.
49+
4150
### Setup Docker Swarm
4251

4352
Initialize swarm
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM debian:bookworm-slim
2+
# This Dockerfile adds a non-root user with sudo access. Use the "remoteUser"
3+
# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs
4+
# will be updated to match your local UID/GID (when using the dockerFile property).
5+
# See https://aka.ms/vscode-remote/containers/non-root-user for details.
6+
ARG USERNAME=vscode
7+
ARG USER_UID=1000
8+
ARG USER_GID=$USER_UID
9+
10+
ENV NVM_DIR=/home/vscode/.nvm
11+
ENV NODE_VERSION=20.13.1
12+
ENV PATH="/home/vscode/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
13+
14+
# Install sudo
15+
RUN apt-get update && apt-get install -y \
16+
sudo \
17+
python3 \
18+
python3-requests \
19+
curl \
20+
git \
21+
procps \
22+
krb5-user \
23+
wait-for-it \
24+
wget \
25+
# Add user, group, and add user to sudoer group
26+
&& groupadd --gid $USER_GID $USERNAME \
27+
&& useradd --no-log-init -r -m -u $USER_UID -g $USER_GID -G sudo -s /bin/bash $USERNAME \
28+
&& echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
29+
&& wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
30+
&& apt-get install -y ./google-chrome-stable_current_amd64.deb \
31+
&& rm ./google-chrome-stable_current_amd64.deb
32+
33+
USER $USERNAME
34+
35+
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash \
36+
&& npm install lerna @nestjs/cli yarn @angular/cli -g
37+
38+
CMD [ "tail", "-f", "/dev/null" ]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
### Add to kerberos
2+
3+
In `kerberos` container:
4+
5+
```shell
6+
kadmin.local -q 'addprinc -x dn=cn=Posix" "User,ou=Users,dc=example,dc=com posix.user'
7+
```
8+
9+
In `development` container:
10+
11+
```shell
12+
wait-for-it kerberos:749
13+
14+
kadmin -p admin -q "addprinc -randkey HTTP/localhost" <<EOF
15+
admin
16+
admin
17+
EOF
18+
19+
sudo kadmin -p admin -q "ktadd HTTP/localhost" <<EOF
20+
admin
21+
admin
22+
EOF
23+
24+
sudo chown -R vscode:root /etc/krb5.keytab
25+
26+
kinit -k HTTP/localhost
27+
28+
klist
29+
```
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
services:
2+
# LDAP
3+
kerberos:
4+
container_name: kerberos
5+
image: nugaon/kerberos-with-ldap:latest
6+
volumes:
7+
- /dev/urandom:/dev/random
8+
ports:
9+
- 8800:88
10+
- 4640:464
11+
- 7490:749
12+
ldap:
13+
image: nugaon/openldap-with-kerberos:latest
14+
container_name: ldap
15+
domainname: "example.com" # important: same as hostname
16+
hostname: "example.com"
17+
environment:
18+
LDAP_LOG_LEVEL: "256"
19+
LDAP_ORGANISATION: "Example"
20+
LDAP_DOMAIN: "example.com"
21+
LDAP_BASE_DN: ""
22+
LDAP_ADMIN_PASSWORD: "admin"
23+
LDAP_CONFIG_PASSWORD: "config"
24+
LDAP_READONLY_USER: "false"
25+
LDAP_READONLY_USER_USERNAME: "readonly"
26+
LDAP_READONLY_USER_PASSWORD: "readonly"
27+
LDAP_RFC2307BIS_SCHEMA: "false"
28+
LDAP_BACKEND: "mdb"
29+
LDAP_TLS: "true"
30+
LDAP_TLS_CRT_FILENAME: "ldap.crt"
31+
LDAP_TLS_KEY_FILENAME: "ldap.key"
32+
LDAP_TLS_CA_CRT_FILENAME: "ca.crt"
33+
LDAP_TLS_ENFORCE: "false"
34+
LDAP_TLS_CIPHER_SUITE: "SECURE256:-VERS-SSL3.0"
35+
LDAP_TLS_PROTOCOL_MIN: "3.1"
36+
LDAP_TLS_VERIFY_CLIENT: "demand"
37+
LDAP_REPLICATION: "false"
38+
#LDAP_REPLICATION_CONFIG_SYNCPROV: "binddn="cn=admin,cn=config" bindmethod=simple credentials=$LDAP_CONFIG_PASSWORD searchbase="cn=config" type=refreshAndPersist retry="60 +" timeout=1 starttls=critical"
39+
#LDAP_REPLICATION_DB_SYNCPROV: "binddn="cn=admin,$LDAP_BASE_DN" bindmethod=simple credentials=$LDAP_ADMIN_PASSWORD searchbase="$LDAP_BASE_DN" type=refreshAndPersist interval=00:00:00:10 retry="60 +" timeout=1 starttls=critical"
40+
#docker-compose.ymlLDAP_REPLICATION_HOSTS: "#PYTHON2BASH:['ldap://ldap.example.com','ldap://ldap2.example.com']"
41+
KEEP_EXISTING_CONFIG: "false"
42+
LDAP_REMOVE_CONFIG_AFTER_SETUP: "false"
43+
LDAP_SSL_HELPER_PREFIX: "ldap"
44+
tty: true
45+
stdin_open: true
46+
volumes:
47+
- ldap-data:/var/lib/ldap
48+
- ldap-config:/etc/ldap/slapd.d
49+
- ldap-certs:/container/service/slapd/assets/certs/
50+
- ./ldif:/container/service/slapd/assets/config/bootstrap/ldif/custom/
51+
ports:
52+
- "389:389"
53+
- "636:636"
54+
55+
phpldapadmin:
56+
image: osixia/phpldapadmin:latest
57+
container_name: ldapadmin
58+
environment:
59+
PHPLDAPADMIN_LDAP_HOSTS: ldap
60+
PHPLDAPADMIN_HTTPS: "false"
61+
ports:
62+
- "8888:80"
63+
depends_on:
64+
- ldap
65+
66+
# Services
67+
event-bus:
68+
image: emqx/emqx:latest
69+
environment:
70+
- EMQX_ALLOW_ANONYMOUS=true
71+
- EMQX_LOADED_PLUGINS=emqx_management,emqx_auth_mnesia,emqx_recon,emqx_retainer,emqx_dashboard
72+
ports:
73+
- 1883:1883
74+
- 18083:18083
75+
- 8081:8081
76+
77+
mongo:
78+
image: bitnami/mongodb:latest
79+
environment:
80+
- "MONGODB_ROOT_PASSWORD=admin"
81+
- "MONGODB_DATABASE=authorization-server"
82+
- "MONGODB_USERNAME=authorization-server"
83+
- "MONGODB_PASSWORD=admin"
84+
volumes:
85+
- mongodb-vol:/bitnami/mongodb
86+
ports:
87+
- 27017:27017
88+
89+
mongo-configuration:
90+
image: bitnami/mongodb:latest
91+
user: root
92+
volumes:
93+
- mongodb-vol:/bitnami
94+
command:
95+
- bash
96+
- -c
97+
- >
98+
chown -R 1001:1001 /bitnami;
99+
sleep 10;
100+
mongosh identity-provider \
101+
--host mongo \
102+
--port 27017 \
103+
--username root \
104+
--password admin \
105+
--authenticationDatabase admin \
106+
--eval "db.createUser({user: 'identity-provider', pwd: 'admin', roles:[{role:'dbOwner', db: 'identity-provider'}]});";
107+
108+
mongosh infrastructure-console \
109+
--host mongo \
110+
--port 27017 \
111+
--username root \
112+
--password admin \
113+
--authenticationDatabase admin \
114+
--eval "db.createUser({user: 'infrastructure-console', pwd: 'admin', roles:[{role:'dbOwner', db: 'infrastructure-console'}]});";
115+
116+
mongosh communication-server \
117+
--host mongo \
118+
--port 27017 \
119+
--username root \
120+
--password admin \
121+
--authenticationDatabase admin \
122+
--eval "db.createUser({user: 'communication-server', pwd: 'admin', roles:[{role:'dbOwner', db: 'communication-server'}]});";
123+
124+
mongosh test_authorization-server \
125+
--host mongo \
126+
--port 27017 \
127+
--username root \
128+
--password admin \
129+
--authenticationDatabase admin \
130+
--eval "db.createUser({user: 'authorization-server', pwd: 'admin', roles:[{role:'dbOwner', db: 'test_authorization-server'}]});"
131+
132+
development:
133+
environment:
134+
- SHELL=/bin/bash
135+
# - XDG_RUNTIME_DIR=/tmp
136+
# - WAYLAND_DISPLAY=${WAYLAND_DISPLAY}
137+
# - DISPLAY=:14
138+
# - LIBGL_ALWAYS_INDIRECT=0
139+
extra_hosts:
140+
example.com: 172.17.0.1
141+
www.example.com: 172.17.0.1
142+
accounts.localhost: 127.0.0.1
143+
admin.localhost: 127.0.0.1
144+
connect.localhost: 127.0.0.1
145+
myaccount.localhost: 127.0.0.1
146+
accounts.example.com: 172.17.0.1
147+
admin.example.com: 172.17.0.1
148+
connect.example.com: 172.17.0.1
149+
myaccount.example.com: 172.17.0.1
150+
build: .
151+
volumes:
152+
- ..:/workspace
153+
- ./krb5-client.conf:/etc/krb5.conf
154+
working_dir: /workspace
155+
156+
volumes:
157+
mongodb-vol:
158+
ldap-data:
159+
ldap-config:
160+
ldap-certs:
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "development",
3+
"remoteEnv": {
4+
"SYNC_LOCALHOST_KUBECONFIG": "true"
5+
},
6+
"dockerComposeFile": "./compose.yml",
7+
"service": "development",
8+
"workspaceFolder": "/workspace",
9+
"shutdownAction": "stopCompose",
10+
"remoteUser": "vscode",
11+
"customizations": {
12+
"vscode": {
13+
"extensions": [
14+
"streetsidesoftware.code-spell-checker",
15+
"dbaeumer.vscode-eslint",
16+
"eamodio.gitlens",
17+
"esbenp.prettier-vscode",
18+
"prettier.prettier-vscode"
19+
]
20+
}
21+
}
22+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[libdefaults]
2+
default_realm = EXAMPLE.COM
3+
# The following krb5.conf variables are only for MIT Kerberos.
4+
kdc_timesync = 1
5+
ccache_type = 4
6+
forwardable = true
7+
proxiable = true
8+
# The following libdefaults parameters are only for Heimdal Kerberos.
9+
fcc-mit-ticketflags = true
10+
11+
[realms]
12+
EXAMPLE.COM = {
13+
kdc = kerberos
14+
admin_server = kerberos
15+
}
16+
17+
[domain_realm]
18+
example.com = EXAMPLE.COM
19+
.example.com = EXAMPLE.COM

0 commit comments

Comments
 (0)