-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 6077 - Provide a Development Container
Bug Description: It would be nice if we had a quick, easy, repeatable, and portable way to build and run this project - specifically in a container. Fix Description: A container specifically intended for getting contributors up and running quickly from anywhere so they can test their PRs. Fixes: #6077
- Loading branch information
1 parent
8fe7586
commit 0bcfd69
Showing
9 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dockerComposeFile": "dev.yaml", | ||
"service": "dirsrv", | ||
"workspaceFolder": "/389-ds-base" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM quay.io/389ds/devcontainer | ||
ARG CUSTOM_CRT_URL | ||
|
||
ARG CUSTOM_CRT_URL | ||
|
||
RUN if [ -z "$CUSTOM_CRT_URL" ] ; then echo "No custom cert needed"; else \ | ||
curl -o /etc/pki/ca-trust/source/anchors/customcert.crt $CUSTOM_CRT_URL \ | ||
&& update-ca-trust \ | ||
; fi \ | ||
&& dnf install -y openssl nss-tools libasan | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# 389 Directory Server Development Container | ||
|
||
## What is this for? | ||
The Development Container simplifies building and running the 389 Directory Server from anywhere including Windows, Mac, and Linux by leveraging a container. The environment is therefore already setup with the correct tools and tool versions to build and run. | ||
|
||
## How does it work | ||
You need to have a local container runtime such as [Docker Desktop](https://www.docker.com/products/docker-desktop/), [Podman](https://podman.io/), or [Kubernetes](https://kubernetes.io/). [Docker Compose](https://docs.docker.com/compose/) is recommended as well to simplify commands, and avoid long repetitive command lines, but not strictly required. If you don't have Docker Compose you will need to examine the `dev.yaml` and translate to container run commands. Container run commands with Kubernetes also [requires translation](https://kubernetes.io/docs/reference/kubectl/docker-cli-to-kubectl/). | ||
|
||
By default, the project directory is bind mounted into the container such that changes can be made on the local workstation using your favorite IDE. Other modes of operation are possible such as editing in-container or using remote development tooling such as [VS Code](https://code.visualstudio.com/docs/remote/remote-overview) or [IntelliJ](https://www.jetbrains.com/remote-development/). | ||
|
||
## Get and start development container: | ||
``` | ||
git clone https://github.com/389ds/389-ds-base | ||
cd 389-ds-base | ||
docker compose -f dev.yaml up | ||
``` | ||
|
||
## Build and Run inside the container: | ||
``` | ||
docker exec -it bash dirsrv | ||
cd 389-ds-base | ||
./build.sh | ||
/usr/libexec/dirsrv/dscontainer -r & | ||
# Or run dsctl, etc. | ||
``` | ||
|
||
## Configure: | ||
You can configure the development container using environment variables. Create a [dev-overrides.env](https://docs.docker.com/compose/environment-variables/set-environment-variables/) file in the project root. | ||
|
||
Container Runtime Environment Variables: | ||
|
||
| Name | Description | Default | | ||
|------------------|-------------------------------------------------------|-------------------| | ||
| CC | C compiler | gcc | | ||
| CXX | C++ compiler | g++ | | ||
| CFLAGS | C compiler flags | "-O2 -g" | | ||
| CXXFLAGS | C++ compiler flags | | | ||
| LDFLAGS | Linker flags | | | ||
| DS_BACKEND_NAME | Development database backend | example | | ||
| DS_DM_PASSWORD | Development Directory Manager password | password | | ||
| DS_START_TIMEOUT | Number of seconds to start dscontainer before timeout | 60 | | ||
| DS_STOP_TIMEOUT | Number of seconds to stop dscontainer before timeout | 60 | | ||
| DS_SUFFIX_NAME | Development database suffix | dc=example,dc=com | | ||
|
||
The development container actually runs a container build and at container build-time you can set environment variables by creating a `.env` file. At the moment the only build time environment variable is "CUSTOM_CRT_URL", which can be used to set a self-signed cert URL to thwart corporate TLS proxies. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
autoreconf -fiv | ||
./configure --enable-debug --with-openldap --enable-cmocka --enable-asan | ||
make | ||
make lib389 | ||
make install | ||
make lib389-install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CC=gcc | ||
CXX=g++ | ||
CFLAGS="-O2 -g" | ||
CXXFLAGS="" | ||
LDFLAGS="" | ||
DS_DM_PASSWORD=password | ||
DS_SUFFIX_NAME=dc=example,dc=com | ||
DS_BACKEND_NAME=example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
services: | ||
dirsrv: | ||
build: | ||
context: . | ||
dockerfile: Containerfile-dev | ||
args: | ||
CUSTOM_CRT_URL: ${CUSTOM_CRT_URL} | ||
hostname: dirsrv | ||
container_name: dirsrv | ||
ports: | ||
- "3389:3389" | ||
- "3636:3636" | ||
init: true | ||
entrypoint: ["sleep", "infinity"] | ||
cap_add: | ||
- SYS_PTRACE | ||
env_file: | ||
- path: ./dev-defaults.env | ||
required: true | ||
- path: ./dev-overrides.env | ||
required: false | ||
volumes: | ||
- ./:/389-ds-base |