Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support post-startup script in libreoffice devcontainer #113

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions features/src/workbench-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

# Hello, World! (hello)

A hello world feature

## Example Usage

```json
"features": {
"ghcr.io/devcontainers/feature-starter/hello:1": {
"version": "latest"
}
}
```

## Options

| Options Id | Description | Type | Default Value |
|-----|-----|-----|-----|
| greeting | Select a pre-made greeting, or enter your own | string | hey |



---

_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/devcontainers/feature-starter/blob/main/src/hello/devcontainer-feature.json). Add additional notes to a `NOTES.md`._
22 changes: 22 additions & 0 deletions features/src/workbench-cli/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "Hello, World!",
"id": "hello",
"version": "1.0.2",
"description": "A hello world feature",
"options": {
"greeting": {
"type": "string",
"proposals": [
"hey",
"hello",
"hi",
"howdy"
],
"default": "hey",
"description": "Select a pre-made greeting, or enter your own"
}
},
"installsAfter": [
"ghcr.io/devcontainers/features/common-utils"
]
}
29 changes: 29 additions & 0 deletions features/src/workbench-cli/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh
set -e

echo "Activating feature 'hello'"

GREETING=${GREETING:-undefined}
echo "The provided greeting is: $GREETING"

# The 'install.sh' entrypoint script is always executed as the root user.
#
# These following environment variables are passed in by the dev container CLI.
# These may be useful in instances where the context of the final
# remoteUser or containerUser is useful.
# For more details, see https://containers.dev/implementors/features#user-env-var
echo "The effective dev container remoteUser is '$_REMOTE_USER'"
echo "The effective dev container remoteUser's home directory is '$_REMOTE_USER_HOME'"

echo "The effective dev container containerUser is '$_CONTAINER_USER'"
echo "The effective dev container containerUser's home directory is '$_CONTAINER_USER_HOME'"

cat > /usr/local/bin/hello \
<< EOF
#!/bin/sh
RED='\033[0;91m'
NC='\033[0m' # No Color
echo "\${RED}${GREETING}, \$(whoami)!\${NC}"
EOF

chmod +x /usr/local/bin/hello
29 changes: 29 additions & 0 deletions src/libreoffice/.devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "Libreoffice app",
"dockerComposeFile": "docker-compose.yaml",
"service": "app",
"shutdownAction": "none",
"workspaceFolder": "/workspace",
"postCreateCommand": [
"./startupscript/post-startup.sh",
"abc",
"/config",
"gcp",
"true"
],
// re-mount bucket files on container start up
"postStartCommand": [
"./startupscript/remount-on-restart.sh",
"abc",
"/config",
"gcp",
"true"
],
"remoteUser": "root",
"features": {
"./.devcontainer/features/workbench-cli": {}
// "./.devcontainer/features/src/java": {
// "version": "17"
// }
}
}
1 change: 1 addition & 0 deletions src/libreoffice/.devcontainer/features
14 changes: 14 additions & 0 deletions src/libreoffice/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Rstudio (rstudio)

A Template to run rstudio on workbench

## Options

| Options Id | Description | Type | Default Value |
| ---------- | ---------------------------------- | ------ | ------------- |
| cloud | VM cloud environment | string | gcp |
| login | Whether to log in to workbench CLI | string | false |

---

_Note: This file was auto-generated from the [devcontainer-template.json](https://github.com/verily-src/workbench-app-devcontainers/blob/main/src/rstudio/devcontainer-template.json). Add additional notes to a `NOTES.md`._
23 changes: 23 additions & 0 deletions src/libreoffice/devcontainer-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"id": "libreoffice",
"version": "0.1.0",
"name": "Libreoffice",
"description": "A Template to libreoffice on workbench",
"documentationURL": "https://github.com/verily-src/workbench-app-devcontainers/tree/master/src/libreoffice",
"licenseURL": "https://github.com/verily-src/workbench-app-devcontainers/blob/master/LICENSE",
"options": {
"cloud": {
"type": "string",
"description": "VM cloud environment",
"proposals": ["gcp", "aws"],
"default": "gcp"
},
"login": {
"type": "string",
"description": "Whether to log in to workbench CLI",
"proposals": ["true", "false"],
"default": "false"
}
},
"platforms": ["Any"]
}
24 changes: 24 additions & 0 deletions src/libreoffice/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: "2.4"
services:
app:
container_name: "application-server"
image: "lscr.io/linuxserver/libreoffice:latest"
restart: always
volumes:
- .:/workspace:cached
- work:/config:cached
ports:
- "3000:3000"
networks:
- app-network
cap_add:
- SYS_ADMIN
devices:
- /dev/fuse
security_opt:
- apparmor:unconfined
networks:
app-network:
external: true
volumes:
work:
4 changes: 2 additions & 2 deletions startupscript/install-java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
# - USER_PRIMARY_GROUP: name of primary group app user belongs to

# Check if the user name is provided.
ln -sf "$(which java)" "/usr/bin"
chown --no-dereference "${USER_NAME}:${USER_PRIMARY_GROUP}" "/usr/bin/java"
#ln -sf "$(which java)" "/usr/bin"
#chown --no-dereference "${USER_NAME}:${USER_PRIMARY_GROUP}" "/usr/bin/java"

10 changes: 7 additions & 3 deletions startupscript/post-startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ ${RUN_AS_LOGIN_USER} "ln -sf '${USER_WORKBENCH_CONFIG_DIR}' '${USER_WORKBENCH_LE
exec >> "${POST_STARTUP_OUTPUT_FILE}"
exec 2>&1

# The apt package index may not be clean when we run; resynchronize
apt-get update
apt install -y jq curl fuse tar wget
# Test for apt-get being present.
which apt-get && true
if [[ $? -eq 0 ]]; then
# The apt package index may not be clean when we run; resynchronize
apt-get update
apt install -y jq curl fuse tar wget
fi

# Create the target directories for installing into the HOME directory
${RUN_AS_LOGIN_USER} "mkdir -p '${USER_BASH_COMPLETION_DIR}'"
Expand Down