Skip to content

Commit be6b2a1

Browse files
committed
Add some Docker infra for testing
...
1 parent aa00cbf commit be6b2a1

11 files changed

+517
-2
lines changed

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.git
2+
*.o
3+
*.d
4+
obj/
5+
derived_src/
6+
config.make
7+
.makeenv/

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ obj
66
config.make
77
Database/OGoModel/OGo.model/
88
.nova
9+
OGo.env
10+
docker-compose.yml
911

GNUmakefile

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
-include ./config.make
44

5-
ifeq ($(GNUSTEP_MAKEFILES),)
5+
ifeq ($(wildcard $(GNUSTEP_MAKEFILES)/common.make),)
66

7-
$(warning Note: Your $(GNUSTEP_MAKEFILES) environment variable is empty!)
7+
$(warning Note: GNUstep makefiles not found.)
88
$(warning Either use ./configure or source GNUstep.sh.)
99

1010
else
@@ -27,6 +27,21 @@ include $(GNUSTEP_MAKEFILES)/aggregate.make
2727
endif
2828

2929

30+
# Docker local build
31+
32+
DOCKER_TAG = ogo-local-dev:latest
33+
DOCKER_FILE = docker/OGoLocalBuild.dockerfile
34+
35+
docker-build:
36+
docker build -t $(DOCKER_TAG) -f $(DOCKER_FILE) .
37+
38+
docker-run:
39+
docker compose up
40+
41+
docker-clean:
42+
docker rmi $(DOCKER_TAG) 2>/dev/null || true
43+
44+
3045
distclean ::
3146
if test -f config.make; then rm config.make; fi
3247
if test -d .makeenv; then rm -r .makeenv; fi

README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,103 @@ sources are licensed under the GNU Lesser General Public License and
142142
the copyright is owned by SKYRIX Software AG.
143143

144144

145+
### Running OGo in Docker
146+
147+
OGo can be built and run as a Docker image for local testing.
148+
149+
#### Prerequisites
150+
151+
A PostgreSQL server must be reachable from the container.
152+
The easiest way is to run PostgreSQL in Docker as well and
153+
connect the containers via a shared Docker network.
154+
155+
Create the external Docker networks that the compose file
156+
expects:
157+
158+
```bash
159+
docker network create postgres
160+
```
161+
162+
The `postgres` network must contain a PostgreSQL container
163+
(hostname `postgres`) with the OGo database already set up
164+
(see GitHub Wiki).
165+
166+
#### Building the Image
167+
168+
```bash
169+
make docker-build
170+
```
171+
172+
This builds the `ogo-local-dev:latest` image from local
173+
sources using `docker/OGoLocalBuild.dockerfile`.
174+
175+
#### Example docker-compose.yml
176+
177+
The `docker-compose.yml` is git-ignored, create your own
178+
in the repository root:
179+
180+
```yaml
181+
networks:
182+
postgres:
183+
external: true
184+
185+
services:
186+
opengroupware:
187+
container_name: ogo-local-dev
188+
image: ogo-local-dev:latest
189+
restart: always
190+
networks:
191+
- postgres
192+
volumes:
193+
- ./data/docs:/var/lib/opengroupware.org/documents
194+
- ./data/news:/var/lib/opengroupware.org/news
195+
env_file: "OGo.env"
196+
environment:
197+
- OGO_SERVER_PROTOCOL=http
198+
- OGO_SERVER_NAME=localhost
199+
- OGO_SERVER_PORT=80
200+
- OGO_INSTANCE_COUNT=1
201+
- OGO_INSTANCE_ID=OGo
202+
- OGO_DATABASE_NAME=OGo
203+
- OGO_DATABASE_USER=OGo
204+
- OGO_DATABASE_HOST=postgres
205+
- OGO_DATABASE_PORT=5432
206+
ports:
207+
- 8080:80
208+
```
209+
210+
#### Credentials
211+
212+
Create an `OGo.env` file in the repository root (it is
213+
git-ignored). This file supplies the database password to
214+
the container:
215+
216+
```
217+
OGO_DATABASE_PASSWORD=<your-password>
218+
```
219+
220+
All other configuration (database host, port, user, etc.)
221+
is set inline in `docker-compose.yml` via the `environment`
222+
section.
223+
224+
#### Running
225+
226+
```bash
227+
make docker-run
228+
```
229+
230+
This runs `docker compose up` in the foreground. OGo will
231+
be available at `http://localhost:8080/OpenGroupware`.
232+
Press Ctrl-C to stop the stack.
233+
234+
#### Volume Mounts
235+
236+
The `docker-compose.yml` contains example volume mounts for
237+
documents, news, and SkyFS storage. Adjust the host paths
238+
to match your local data directories, or comment them out
239+
for a fresh install.
240+
241+
145242
### Contact
146243

147244
[@helge@mastodon.social](https://mastodon.social/@helge)

docker/Dev-globaldomain.plist

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>NGBundlePath</key>
6+
<string>/usr/local/lib/GNUstep/Bundles:/usr/local/lib/GNUstep/Models-5.5:/usr/local/lib/GNUstep/Commands-5.5:/usr/local/lib/GNUstep/WOxElemBuilders-4.9</string>
7+
<key>WOCoreOnHTTPAdaptorException</key>
8+
<string>YES</string>
9+
</dict>
10+
</plist>

docker/Dev-webui.plist

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>NGBundlePath</key>
6+
<string>/usr/local/lib/GNUstep/Bundles:/usr/local/lib/GNUstep/Models-5.5:/usr/local/lib/GNUstep/Commands-5.5:/usr/local/lib/GNUstep/WOxElemBuilders-4.9:/usr/local/lib/GNUstep/WebUI-5.5</string>
7+
<key>NGLogDefaultLogLevel</key>
8+
<string>DEBUG</string>
9+
<key>PGDebugEnabled</key>
10+
<string>YES</string>
11+
<key>SkyLogoutURL</key>
12+
<string>/OpenGroupware</string>
13+
<key>WONoDetach</key>
14+
<string>YES</string>
15+
<key>WOLogFile</key>
16+
<string>-</string>
17+
<key>WORunMultithreaded</key>
18+
<string>NO</string>
19+
<key>WOUseWatchDog</key>
20+
<string>NO</string>
21+
</dict>
22+
</plist>

docker/OGo-globaldomain.plist

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>NGBundlePath</key>
6+
<string>/usr/local/lib/GNUstep/Bundles:/usr/local/lib/GNUstep/Models-5.5:/usr/local/lib/GNUstep/Commands-5.5:/usr/local/lib/GNUstep/WOxElemBuilders-4.9</string>
7+
<key>WOCoreOnHTTPAdaptorException</key>
8+
<string>NO</string>
9+
</dict>
10+
</plist>

docker/OGo-webui.plist

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>NGBundlePath</key>
6+
<string>/usr/local/lib/GNUstep/Bundles:/usr/local/lib/GNUstep/Models-5.5:/usr/local/lib/GNUstep/Commands-5.5:/usr/local/lib/GNUstep/WOxElemBuilders-4.9:/usr/local/lib/GNUstep/WebUI-5.5</string>
7+
<key>NGLogDefaultLogLevel</key>
8+
<string>WARN</string>
9+
<key>PGDebugEnabled</key>
10+
<string>NO</string>
11+
<key>SkyLogoutURL</key>
12+
<string>/OpenGroupware</string>
13+
<key>WONoDetach</key>
14+
<string>NO</string>
15+
<key>WORunMultithreaded</key>
16+
<string>NO</string>
17+
<key>WOUseWatchDog</key>
18+
<string>YES</string>
19+
</dict>
20+
</plist>

docker/OGoLocalBuild.dockerfile

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# Dockerfile
2+
#
3+
# OpenGroupware Local Build Image
4+
#
5+
# Like OGoDevImage, but builds from local sources (COPY)
6+
# instead of fetching a tagged release from GitHub.
7+
#
8+
# Build from the OGo repo root:
9+
# docker build -t ogo-local-dev -f docker/OGoLocalBuild.dockerfile .
10+
#
11+
FROM ubuntu:noble
12+
13+
LABEL maintainer="Helge Heß <me@helgehess.eu>"
14+
15+
ENV DEBIAN_FRONTEND=noninteractive
16+
17+
# Install the things necessary for OGo, but also a set of debug
18+
# tooling to work on issues.
19+
# A real deployment image shouldn't do this once considered stable.
20+
RUN apt-get -y -qq update \
21+
&& apt-get -y -qq upgrade \
22+
&& apt-get -y -qq install \
23+
libxml2-dev libldap2 libldap-dev libpq-dev libpq5 \
24+
libmemcached-dev libmemcached-tools libcurl4-openssl-dev \
25+
libcrypt-dev make libz-dev \
26+
gobjc \
27+
gnustep-make \
28+
gnustep-base-runtime \
29+
libgnustep-base-dev \
30+
zip \
31+
emacs less tree file \
32+
sudo gdb linux-tools-generic strace \
33+
netcat-openbsd lsof psmisc \
34+
git \
35+
links curl wget2 \
36+
vim \
37+
postgresql-client \
38+
apache2 \
39+
apache2-bin \
40+
apache2-data \
41+
apache2-utils
42+
43+
44+
# Grab the SOPE sources from GitHub (tagged release, cached layer).
45+
ENV SOPE_VERSION=6.0.6
46+
ENV OGO_SOVERSION=5.5
47+
ENV OGO_VERSION=${OGO_SOVERSION}.25
48+
ENV OGO_ORGANIZATION=https://github.com/OpenGroupware
49+
ENV SOPE_REPO=${OGO_ORGANIZATION}/SOPE
50+
51+
RUN mkdir /src
52+
ADD ${SOPE_REPO}/archive/refs/tags/${SOPE_VERSION}.tar.gz \
53+
/src/SOPE.tar.gz
54+
WORKDIR /src
55+
RUN tar zxf SOPE.tar.gz && rm SOPE.tar.gz
56+
57+
58+
# Compile and install SOPE
59+
WORKDIR /src/SOPE-${SOPE_VERSION}
60+
RUN ./configure \
61+
--with-gnustep \
62+
--enable-xml \
63+
--enable-postgresql \
64+
--enable-openldap \
65+
--with-ssl=ssl \
66+
--enable-debug \
67+
--disable-strip \
68+
&& make -j 8 \
69+
&& make install
70+
71+
72+
# Copy local OGo sources into the image
73+
COPY . /src/OGo
74+
75+
# Backward-compat symlink so startup scripts that reference
76+
# /src/OpenGroupware.org-<version>/... keep working.
77+
RUN ln -s /src/OGo \
78+
/src/OpenGroupware.org-${OGO_VERSION}
79+
80+
# Compile and install OGo
81+
WORKDIR /src/OGo
82+
RUN ./configure \
83+
--with-gnustep \
84+
--gsmake=/usr/share/GNUstep/Makefiles \
85+
--enable-debug \
86+
--disable-strip \
87+
&& make -j 8 \
88+
&& make install
89+
90+
# Add some necessary links
91+
RUN mkdir /usr/local/share/opengroupware.org-${OGO_SOVERSION}/ \
92+
&& ln -s /src/OGo/Themes/WebServerResources \
93+
/usr/local/share/opengroupware.org-${OGO_SOVERSION}/www \
94+
&& ln -s /src/OGo/WebUI/Templates \
95+
/usr/local/share/opengroupware.org-${OGO_SOVERSION}/templates \
96+
&& ln -s /src/OGo/WebUI/Resources \
97+
/usr/local/share/opengroupware.org-${OGO_SOVERSION}/translations
98+
99+
100+
# Enable the necessary Apache modules
101+
RUN a2enmod proxy \
102+
&& a2enmod proxy_http \
103+
&& a2enmod proxy_balancer \
104+
&& a2enmod lbmethod_byrequests \
105+
&& a2enmod headers
106+
107+
108+
# Add OGo User
109+
USER root
110+
RUN useradd -u 700 --create-home --shell /bin/bash OGo
111+
112+
USER OGo
113+
114+
RUN mkdir -p /home/OGo/GNUstep/Defaults
115+
COPY docker/OGo-globaldomain.plist \
116+
/home/OGo/GNUstep/Defaults/NSGlobalDomain.plist
117+
COPY docker/OGo-webui.plist \
118+
/home/OGo/GNUstep/Defaults/ogo-webui-5.5.plist
119+
120+
121+
# Add a user for development purposes.
122+
# 501 is the macOS UID of the default user, gives us proper
123+
# permissions
124+
USER root
125+
RUN useradd -u 501 --create-home --shell /bin/bash developer \
126+
&& adduser developer sudo \
127+
&& adduser developer root \
128+
&& usermod -aG sudo developer
129+
130+
USER developer
131+
RUN mkdir -p /home/developer/GNUstep/Defaults
132+
COPY docker/Dev-globaldomain.plist \
133+
/home/developer/GNUstep/Defaults/NSGlobalDomain.plist
134+
COPY docker/Dev-webui.plist \
135+
/home/developer/GNUstep/Defaults/ogo-webui-5.5.plist
136+
137+
USER root
138+
COPY docker/startup-opengroupware /usr/local/bin/
139+
COPY docker/startup-opengroupware-stack /usr/local/bin/
140+
RUN mkdir /var/run/opengroupware \
141+
&& chown OGo /var/run/opengroupware \
142+
&& mkdir /var/log/opengroupware \
143+
&& chown OGo /var/log/opengroupware
144+
145+
# this should be set on the outside to a globally unique value
146+
ENV OGO_INSTANCE_ID=OGo
147+
148+
ENV OGO_DATABASE_NAME=OGo
149+
ENV OGO_DATABASE_USER=OGo
150+
ENV OGO_DATABASE_PASSWORD=OGo
151+
ENV OGO_DATABASE_HOST=postgres
152+
ENV OGO_DATABASE_PORT=5432
153+
154+
# How many OGo Instances should be booted up.
155+
ENV OGO_INSTANCE_COUNT=10
156+
# Apache VServer Name, used for redirects!
157+
ENV OGO_SERVER_NAME=localhost
158+
ENV OGO_SERVER_PORT=443
159+
ENV OGO_SERVER_PROTOCOL=https
160+
ENV OGO_SERVER_ADMIN=webmaster@${OGO_SERVER_NAME}
161+
162+
163+
# Default Startup
164+
# Let's run Apache on 80, the default port
165+
EXPOSE 80
166+
167+
USER root
168+
WORKDIR /tmp
169+
170+
# https://httpd.apache.org/docs/2.4/stopping.html#gracefulstop
171+
STOPSIGNAL SIGWINCH
172+
173+
CMD [ "startup-opengroupware-stack" ]

0 commit comments

Comments
 (0)