Skip to content

Commit 6583617

Browse files
authored
Move configuration and data up into /config (#2)
* move config and data up into `/config` * use correct version number for build (without `-dev` suffix)
1 parent 15d08fa commit 6583617

8 files changed

Lines changed: 74 additions & 25 deletions

File tree

Containerfile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ ARG UPSTREAM_JQ
2525
ARG TARBALL_JQ
2626

2727
RUN fetch -qo /latest.json "${UPSTREAM_URL}" && \
28-
echo $(jq -r "${UPSTREAM_JQ}" /latest.json) > /version && \
28+
echo $(jq -r "${UPSTREAM_JQ}" /latest.json | sed 's/v//') > /version && \
2929
echo $(jq -r "${TARBALL_JQ}" /latest.json) > /tarball_url
3030

31-
ARG CACHB=2
3231
# Fetch and extract source tarball
3332
RUN fetch -qo /tmp/opencloud.tar.gz "$(cat /tarball_url)" && \
3433
mkdir -m 0755 /opencloud && \
@@ -47,8 +46,11 @@ RUN for f in $(find /patches -name "*.patch");do \
4746
done
4847

4948
RUN go install github.com/bwplotka/bingo@latest
50-
RUN EDITION=rolling gmake clean generate
51-
RUN EDITION=rolling gmake -C opencloud build
49+
50+
ARG EDITION=rolling
51+
52+
RUN EDITION="${EDITION}" gmake clean generate VERSION=$(cat /version)
53+
RUN EDITION="${EDITION}" gmake -C opencloud build VERSION=$(cat /version)
5254

5355

5456
FROM ghcr.io/daemonless/base:${BASE_VERSION}
@@ -92,14 +94,17 @@ LABEL org.opencontainers.image.title="OpenCloud" \
9294
COPY --from=builder --chmod=0755 --chown=bsd:bsd /opencloud/opencloud/bin/opencloud /app/opencloud
9395

9496
# Record version information
95-
RUN su -m bsd -c "/app/opencloud version --skip-services 2>/dev/null" | sed -n 's/^Version: \(.*\)\+.*$/\1/p' > /app/version
97+
RUN su -m bsd -c "/app/opencloud version --skip-services 2>/dev/null" | sed -n 's/^Version: \(.*\)$/\1/p' > /app/version
9698

9799
# Copy root filesystem
98100
COPY root/ /
99101

100102
# Set permissions
101103
RUN chmod +x /etc/services.d/opencloud/run /healthz
102104

105+
ENV OC_CONFIG_DIR=${OC_CONFIG_DIR:-/config/config/}
106+
ENV OC_BASE_DATA_PATH=${OC_BASE_DATA_PATH:-/config/}
107+
103108
# --- Expose (Injected by Generator) ---
104109
EXPOSE 9200
105110

Containerfile.j2

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ ARG UPSTREAM_JQ
1919
ARG TARBALL_JQ
2020

2121
RUN fetch -qo /latest.json "${UPSTREAM_URL}" && \
22-
echo $(jq -r "${UPSTREAM_JQ}" /latest.json) > /version && \
22+
echo $(jq -r "${UPSTREAM_JQ}" /latest.json | sed 's/v//') > /version && \
2323
echo $(jq -r "${TARBALL_JQ}" /latest.json) > /tarball_url
2424

25-
ARG CACHB=2
2625
# Fetch and extract source tarball
2726
RUN fetch -qo /tmp/opencloud.tar.gz "$(cat /tarball_url)" && \
2827
mkdir -m 0755 /opencloud && \
@@ -41,8 +40,11 @@ RUN for f in $(find /patches -name "*.patch");do \
4140
done
4241

4342
RUN go install github.com/bwplotka/bingo@latest
44-
RUN EDITION=rolling gmake clean generate
45-
RUN EDITION=rolling gmake -C opencloud build
43+
44+
ARG EDITION=rolling
45+
46+
RUN EDITION="${EDITION}" gmake clean generate VERSION=$(cat /version)
47+
RUN EDITION="${EDITION}" gmake -C opencloud build VERSION=$(cat /version)
4648

4749

4850
FROM ghcr.io/daemonless/base:${BASE_VERSION}
@@ -88,14 +90,17 @@ LABEL org.opencontainers.image.title="OpenCloud" \
8890
COPY --from=builder --chmod=0755 --chown=bsd:bsd /opencloud/opencloud/bin/opencloud /app/opencloud
8991

9092
# Record version information
91-
RUN su -m bsd -c "/app/opencloud version --skip-services 2>/dev/null" | sed -n 's/^Version: \(.*\)\+.*$/\1/p' > /app/version
93+
RUN su -m bsd -c "/app/opencloud version --skip-services 2>/dev/null" | sed -n 's/^Version: \(.*\)$/\1/p' > /app/version
9294

9395
# Copy root filesystem
9496
COPY root/ /
9597

9698
# Set permissions
9799
RUN chmod +x /etc/services.d/opencloud/run /healthz
98100

101+
ENV OC_CONFIG_DIR=${OC_CONFIG_DIR:-/config/config/}
102+
ENV OC_BASE_DATA_PATH=${OC_BASE_DATA_PATH:-/config/}
103+
99104
# --- Expose (Injected by Generator) ---
100105
{%- if ports %}
101106
EXPOSE {{ ports | map(attribute='target') | join(' ') }}

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,20 @@ podman run -d --name opencloud \
150150
|------|----------|-------------|
151151
| `9200` | TCP | Web UI |
152152

153+
!!! warning "Work in Progress"
154+
This image is functional but may change significantly in a future release.
155+
156+
## Breaking changes
157+
### untagged -> 0.1.0
158+
- `config` and data directories moved from `/config/.opencloud` to `/config`
159+
Existing data will be moved automatically during container initialization.
160+
153161
## Upgrade from 6.2.0 to 7.0.0
154162
The upgrade requires a change to the configuration of the "sharing" service. Please follow the steps outlined in the [Upgrade Guide](https://docs.opencloud.eu/docs/admin/maintenance/upgrade/upgrade-guide#verify-configuration-changes) to achieve that.
155163

156164
## First run
157-
OpenCloud generates a default config with insecure settings (not TLS validation) on first start
158-
or if the `/config/.opencloud` directory does not exist.
165+
OpenCloud generates a default config with insecure settings (no TLS validation) on first start
166+
or if the file `/config/config/opencloud.yaml` does not exist.
159167

160168
You can define the inital password for the `admin` user by setting the environment variable `IDM_ADMIN_PASSWORD` like this:
161169
```yaml
@@ -166,7 +174,7 @@ services:
166174
```
167175

168176
If you do not set the password with the variable above, OpenCloud generates a random password for the `admin` user and
169-
you can find it in the logs or in the file `/config/.opencloud/config/opencloud.yaml`.
177+
you can find it in the logs or in the file `/config/config/opencloud.yaml`.
170178

171179
## Remarks
172180
So far I have only tested this image with `bridge` networking.

compose.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,20 @@ x-daemonless:
2424
9200: "Web UI"
2525

2626
notes: |
27+
!!! warning "Work in Progress"
28+
This image is functional but may change significantly in a future release.
29+
30+
## Breaking changes
31+
### untagged -> 0.1.0
32+
- `config` and data directories moved from `/config/.opencloud` to `/config`
33+
Existing data will be moved automatically during container initialization.
34+
2735
## Upgrade from 6.2.0 to 7.0.0
2836
The upgrade requires a change to the configuration of the "sharing" service. Please follow the steps outlined in the [Upgrade Guide](https://docs.opencloud.eu/docs/admin/maintenance/upgrade/upgrade-guide#verify-configuration-changes) to achieve that.
2937
3038
## First run
31-
OpenCloud generates a default config with insecure settings (not TLS validation) on first start
32-
or if the `/config/.opencloud` directory does not exist.
39+
OpenCloud generates a default config with insecure settings (no TLS validation) on first start
40+
or if the file `/config/config/opencloud.yaml` does not exist.
3341
3442
You can define the inital password for the `admin` user by setting the environment variable `IDM_ADMIN_PASSWORD` like this:
3543
```yaml
@@ -40,7 +48,7 @@ x-daemonless:
4048
```
4149
4250
If you do not set the password with the variable above, OpenCloud generates a random password for the `admin` user and
43-
you can find it in the logs or in the file `/config/.opencloud/config/opencloud.yaml`.
51+
you can find it in the logs or in the file `/config/config/opencloud.yaml`.
4452
4553
## Remarks
4654
So far I have only tested this image with `bridge` networking.

patches/patch-.make_protobuf.mk.patch

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,12 @@
88
@cd ../.. && GOPATH="" GOBIN=".bingo" $(BINGO) get -l github.com/go-micro/generator/cmd/protoc-gen-micro
99
@cd ../.. && GOPATH="" GOBIN=".bingo" $(BINGO) get -l github.com/owncloud/protoc-gen-microweb
1010
@cd ../.. && GOPATH="" GOBIN=".bingo" $(BINGO) get -l github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2
11+
@@ -16,7 +16,7 @@
12+
.PHONY: buf-generate
13+
buf-generate: $(SHA1_LOCK_FILE)
14+
@find $(abspath $(CURDIR)/../../protogen/proto/) -type f -print0 | sort -z | xargs -0 sha1sum > buf.sha1.lock.tmp
15+
- @cmp $(SHA1_LOCK_FILE) buf.sha1.lock.tmp --quiet || $(MAKE) -B $(SHA1_LOCK_FILE)
16+
+ @cmp -s $(SHA1_LOCK_FILE) buf.sha1.lock.tmp || $(MAKE) -B $(SHA1_LOCK_FILE)
17+
@rm -f buf.sha1.lock.tmp
18+
19+
$(SHA1_LOCK_FILE): $(BUF) protoc-deps
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
# Move the config and data from the old default location
3+
# directly into /config
4+
5+
# Ensure directories exist and have correct ownership
6+
mkdir -p /config
7+
chown -R bsd:bsd /config
8+
9+
if [ ! -d /config/.opencloud ]; then
10+
# If the old base directory does not exist, we do not do anything
11+
exit 0
12+
fi
13+
14+
# Generate default config if missing
15+
if [ ! -d /config/config ]; then
16+
mv /config/.opencloud/* /config
17+
if [ "$?" -eq 0 ]; then
18+
rm -r /config/.opencloud
19+
fi
20+
echo "[move-config] OpenCloud config and data moved from /config/.opencloud to /config"
21+
fi
22+

root/etc/cont-init.d/20-opencloud-init

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mkdir -p /config
66
chown -R bsd:bsd /config
77

88
# Generate default config if missing
9-
if [ ! -d /config/opencloud ]; then
9+
if [ ! -f /config/config/opencloud.yaml ]; then
1010
HOME=/config s6-setuidgid bsd /app/opencloud init --insecure yes || true
1111
fi
1212

root/etc/services.d/opencloud/run

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
#!/bin/sh
22
# OpenCloud s6 service
33

4-
#if [ -z "$TUNNEL_TOKEN" ]; then
5-
# echo "[WARN] TUNNEL_TOKEN is not set. Starting in CIT mock mode."
6-
# # Log version to prove binary is functional
7-
# /usr/local/bin/opencloud --version
8-
# # Listen on port 8080 to satisfy CI port check
9-
# exec /usr/bin/nc -lk 0.0.0.0 8080
10-
#fi
11-
124
echo "[INFO] Starting opencloud..."
135

146
HOME=/config

0 commit comments

Comments
 (0)