mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-26 06:50:36 -05:00
Merge pull request #8238 from 2403905/debug-image
added ability to debug the ocis in a docker compose stack via delve
This commit is contained in:
12
.make/go.mk
12
.make/go.mk
@@ -107,3 +107,15 @@ $(BIN)/$(EXECUTABLE)-debug: $(SOURCES)
|
||||
.PHONY: watch
|
||||
watch: $(REFLEX)
|
||||
$(REFLEX) -c reflex.conf
|
||||
|
||||
debug-linux-docker-amd64: release-dirs
|
||||
GOOS=linux \
|
||||
GOARCH=amd64 \
|
||||
go build \
|
||||
-gcflags="all=-N -l" \
|
||||
-tags 'netgo $(TAGS)' \
|
||||
-buildmode=exe \
|
||||
-trimpath \
|
||||
-ldflags '-extldflags "-static" $(DEBUG_LDFLAGS) $(DOCKER_LDFLAGS)' \
|
||||
-o '$(DIST)/binaries/$(EXECUTABLE)-linux-amd64' \
|
||||
./cmd/$(NAME)
|
||||
|
||||
7
.vscode/launch.json
vendored
7
.vscode/launch.json
vendored
@@ -6,6 +6,13 @@
|
||||
"type": "php",
|
||||
"request": "launch"
|
||||
},
|
||||
{
|
||||
"name": "Debug remote :40000",
|
||||
"type": "go",
|
||||
"request": "attach",
|
||||
"mode": "remote",
|
||||
"port": 40000
|
||||
},
|
||||
{
|
||||
"name": "oCIS server",
|
||||
"type": "go",
|
||||
|
||||
@@ -134,6 +134,52 @@ bin/ocis --log-level=$LOG_LEVEL proxy &
|
||||
|
||||
4. Start the service you are interested in debug mode. When using make to build the binary there is already a `bin/ocis-debug` binary for you. When running an IDE tell it which service to start by providing the corresponding sub command, e.g. `bin\ocis-debug reva-frontend`.
|
||||
|
||||
### Debugging the ocis in a docker container
|
||||
|
||||
Remote debugging is the debug mode commonly used to work with a debugger and target running on a remote machine or a container for example a wopi stack `deployments/examples/ocis_wopi/docker-compose.yml`.
|
||||
Below we describe the steps how to build the image, run the docker-compose and connect via remote debugger.
|
||||
1. Build the image:
|
||||
```bash
|
||||
cd github.com/owncloud/ocis/ocis
|
||||
make debug-docker
|
||||
```
|
||||
2. Change the tag label:
|
||||
```bash
|
||||
export OCIS_DOCKER_TAG=debug
|
||||
```
|
||||
3. Change the docker-compose `ocis` or `ocis-appprovider-collabora` or `ocis-appprovider-onlyoffice` depends on what do you want to debug:
|
||||
For example `deployments/examples/ocis_wopi/docker-compose.yml`
|
||||
```yaml
|
||||
ocis:
|
||||
image: owncloud/ocis:${OCIS_DOCKER_TAG:-latest}
|
||||
networks:
|
||||
ocis-net:
|
||||
entrypoint:
|
||||
- /bin/sh
|
||||
# Comment out command
|
||||
# command: ["-c", "ocis init || true; ocis server"]
|
||||
# Replace the command and expose the port
|
||||
command: [ "-c", "ocis init || true; dlv --listen=:40000 --headless=true --api-version=2 --accept-multiclient exec /usr/bin/ocis server" ]
|
||||
ports:
|
||||
- 40000:40000
|
||||
```
|
||||
4. Run the docker-compose
|
||||
5. Connect to remote `delve`
|
||||
* For the VS Code add the configuration to the `.vscode/launch.json` [https://github.com/golang/vscode-go/wiki/debugging#remote-debugging](https://github.com/golang/vscode-go/wiki/debugging#remote-debugging)
|
||||
```json
|
||||
{
|
||||
"name": "Debug remote :40000",
|
||||
"type": "go",
|
||||
"request": "attach",
|
||||
"mode": "remote",
|
||||
"port": 40000,
|
||||
"host": "localhost", // optional
|
||||
"trace": "verbose", // optional
|
||||
"showLog": true // optional
|
||||
},
|
||||
```
|
||||
|
||||
|
||||
### Gather error messages
|
||||
|
||||
We recommend you collect all related information in a single file or in a GitHub issue. Let us start with an error that pops up in the Web UI:
|
||||
|
||||
@@ -31,6 +31,12 @@ dev-docker:
|
||||
$(MAKE) --no-print-directory release-linux-docker-$(GOARCH)
|
||||
docker build -f docker/Dockerfile.linux.$(GOARCH) -t owncloud/ocis:dev .
|
||||
|
||||
############ debug-docker ############
|
||||
.PHONY: debug-docker
|
||||
debug-docker:
|
||||
$(MAKE) --no-print-directory debug-linux-docker-$(GOARCH)
|
||||
docker build -f docker/Dockerfile.linux.debug.$(GOARCH) -t owncloud/ocis:debug .
|
||||
|
||||
############ generate ############
|
||||
include ../.make/generate.mk
|
||||
|
||||
|
||||
41
ocis/docker/Dockerfile.linux.debug.amd64
Normal file
41
ocis/docker/Dockerfile.linux.debug.amd64
Normal file
@@ -0,0 +1,41 @@
|
||||
FROM amd64/alpine:3.19
|
||||
|
||||
ARG VERSION=""
|
||||
ARG REVISION=""
|
||||
|
||||
RUN apk add --no-cache ca-certificates mailcap tree attr curl libc6-compat delve && \
|
||||
echo 'hosts: files dns' >| /etc/nsswitch.conf
|
||||
|
||||
LABEL maintainer="ownCloud GmbH <devops@owncloud.com>" \
|
||||
org.opencontainers.image.title="ownCloud Infinite Scale" \
|
||||
org.opencontainers.image.vendor="ownCloud GmbH" \
|
||||
org.opencontainers.image.authors="ownCloud GmbH" \
|
||||
org.opencontainers.image.description="oCIS - ownCloud Infinite Scale is a modern file-sync and share platform" \
|
||||
org.opencontainers.image.licenses="Apache-2.0" \
|
||||
org.opencontainers.image.documentation="https://github.com/owncloud/ocis" \
|
||||
org.opencontainers.image.url="https://hub.docker.com/r/owncloud/ocis" \
|
||||
org.opencontainers.image.source="https://github.com/owncloud/ocis" \
|
||||
org.opencontainers.image.version="${VERSION}" \
|
||||
org.opencontainers.image.revision="${REVISION}"
|
||||
|
||||
RUN addgroup -g 1000 -S ocis-group && \
|
||||
adduser -S --ingroup ocis-group --uid 1000 ocis-user --home /var/lib/ocis
|
||||
|
||||
RUN mkdir -p /var/lib/ocis && \
|
||||
chown -R ocis-user:ocis-group /var/lib/ocis && \
|
||||
chmod -R 751 /var/lib/ocis && \
|
||||
mkdir -p /etc/ocis && \
|
||||
chown -R ocis-user:ocis-group /etc/ocis && \
|
||||
chmod -R 751 /etc/ocis
|
||||
|
||||
VOLUME [ "/var/lib/ocis", "/etc/ocis" ]
|
||||
WORKDIR /var/lib/ocis
|
||||
|
||||
USER 1000
|
||||
|
||||
EXPOSE 9200/tcp
|
||||
|
||||
ENTRYPOINT ["/usr/bin/ocis"]
|
||||
CMD ["server"]
|
||||
|
||||
COPY dist/binaries/ocis-linux-amd64 /usr/bin/ocis
|
||||
Reference in New Issue
Block a user