Skip to content

Commit

Permalink
'dev style' container works, except for reverse proxy setup, when avo…
Browse files Browse the repository at this point in the history
…iding the globally configured DNS mapping for the xqiz.it domain, which resolves to 127.0.0.1 which causes some trouble to reroute stuff. For the use case 'docker run --pull' from the Internet, we would ideally like to have the release flow for the XDK finished, and it also has a higher priority, so temporarily pausing to do that.
  • Loading branch information
lagergren committed Mar 14, 2024
1 parent 19dcf91 commit a003554
Show file tree
Hide file tree
Showing 16 changed files with 203 additions and 130 deletions.
13 changes: 13 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# This env file is not the same as the one in docker compose env_file sections.
# This sets a default enviromnent from the build, e.g. with build args.
# The others set environment variables to be used in the container.
#
COMPOSE_PROJECT_NAME=platform

GITHUB_BRANCH_PLATFORM=${GITHUB_BRANCH:-platform-xtcplugin}

PLATFORM_HOSTNAME=${PLATFORM_HOSTNAME:-xtc-platform.container.xqiz.it}
PLATFORM_HOSTNAME_DEV=${PLATFORM_HOSTNAME_DEV:-xtc-platform.container-dev.xqiz.it}

XTC_VERSION=0.4.3
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,9 @@ prj/
# Gradle caches
#
.gradle

#
# Local environment with secrets for Docker compose (or any other system specific thing that
# should not go into source control)
#
.env.local
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ as a container/Dockerfile/docker in the near future, so that you won't have to d
4. Make sure you can ping the local platform address:

```
ping xtc-platform2.localhost.xqiz.it
ping xtc-platform.localhost.xqiz.it
```

The domain name `xtc-platform.localhost.xqiz.it` should resolve to `127.0.0.1`. This allows the same xqiz.it
Expand Down
81 changes: 42 additions & 39 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,48 @@ dependencies {
xtcModule(project(":platformUI")) // runtime path
}

// TODO: Automatically run a pre-pass to verify that the XTC init script is in place (until we are
// on Maven Central (and have a new XDK release from "master"that supports the XTC Plugin).
/**
* Gather all compiled XTC modules from subprojects into a single location: $rootProject/build/platform.
*/
val commonXtcOutputDir = layout.buildDirectory.dir("platform")

allprojects {
tasks.withType<XtcCompileTask>().configureEach {
//outputs.dir(commonXtcOutputDir)
doLast {
copy {
val compilerOutput = outputs.files.asFileTree
compilerOutput.forEach {
logger.lifecycle("XTC module output: ${it.absolutePath} -> ${commonXtcOutputDir.get().asFile.absolutePath}")
}
from(compilerOutput)
into(commonXtcOutputDir)
}
}
}
}

/**
* This is the run configuration, which configures all xtcRun taks for the main source set. (runXtc, runAllXtc)
* The DSL for modules to run is a list of "module { }" elements or a list of moduleName("...") statements.
* To look at the DSL for all parts of the XTC build, you can use your IDE and browse the implementing
* classes. For example, there should be a hint in IntelliJ with the type for the xtcRun element and
* the modules element (DefaultXtcRuntimeExtension and XtcRuntimeExtension.XtcRunModule, respectively).
* It is a good way to understand how the build DSL works, so you can add your own powerful XTC build
* syntax constructs and nice syntactic sugar/shorthand for things you feel should be simpler to write.
*/
xtcRun {
debug = false // Set to true to get the launcher to pause and wait for a debugger to attach.
verbose = true
stdin = System.`in` // Prevent Gradle from eating stdin; make it interactive with the Gradle process that executes the kernel.
module {
moduleName = "kernel"
moduleArg(passwordProvider)
//findProperty("keystorePassword")?.also {
// moduleArg(it.toString())
//}
}
}

/**
* Lazy password resolution provider.
Expand Down Expand Up @@ -66,43 +106,6 @@ internal val passwordProvider: Provider<String> = provider {
findProperty("keystorePassword")?.toString() ?: ""
}

/**
* Gather all compiled XTC modules from subprojects into a single location: $rootProject/build/platform.
*/
val commonXtcOutputDir = layout.buildDirectory.dir("platform")

allprojects {
tasks.withType<XtcCompileTask>().configureEach {
doLast {
copy {
from(outputs.files.asFileTree)
into(commonXtcOutputDir)
}
}
}
}

/**
* This is the run configuration, which configures all xtcRun taks for the main source set. (runXtc, runAllXtc)
* The DSL for modules to run is a list of "module { }" elements or a list of moduleName("...") statements.
* To look at the DSL for all parts of the XTC build, you can use your IDE and browse the implementing
* classes. For example, there should be a hint in IntelliJ with the type for the xtcRun element and
* the modules element (DefaultXtcRuntimeExtension and XtcRuntimeExtension.XtcRunModule, respectively).
* It is a good way to understand how the build DSL works, so you can add your own powerful XTC build
* syntax constructs and nice syntactic sugar/shorthand for things you feel should be simpler to write.
*/
xtcRun {
verbose = true
//fork = false
stdin = System.`in` // Prevent Gradle from eating stdin; make it interactive with the Gradle process that executes the kernel.
module {
moduleName = "kernel"
findProperty("keystorePassword")?.also {
moduleArg(it.toString())
}
}
}

/**
* Run the XTC Platform. Note that this is a Gradle job, and as such gets is dependencies from the module path
* in the Gradle plugin for all source in the project. It will use a module path precisely including
Expand Down
38 changes: 31 additions & 7 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,45 @@ services:
# TODO: Create a platform that is more "dev container" style, and
platform:
image: ghcr.io/xtclang/xdk-platform:latest
env_file:
- .env.local
build:
context: docker
dockerfile: Dockerfile.platform
context: .
dockerfile: docker/Dockerfile.platform
args:
DOCKER_BUILDKIT: 1
PLATFORM_PASSWORD: ${PLATFORM_PASSWORD:-password}
GITHUB_BRANCH_PLATFORM: ${GITHUB_BRANCH_PLATFORM:-platform-xtcplugin}
hostname: ${PLATFORM_HOSTNAME:-xtc-platform.local.xqiz.it}
ports:
- "8080:8080"
- "8090:8090"

#
# Container that grabs, updates and persists source code for 'platform'
# from GitHub, and enabled cached builds in a container.
#
# A third option would be to start a dev container where the root directory
# of the platform project just is symlinked, so you can build and test yourself
# in a normal environment but get deployed elsewhere.
#
dev:
image: ghcr.io/xtclang/xdk-platform-dev:latest
depends_on:
- platform
build:
context: .
dockerfile: docker/Dockerfile.platform.dev
args:
#PLATFORM_PASSWORD: ${PLATFORM_PASSWORD:-password}
GITHUB_BRANCH_PLATFORM: $GITHUB_BRANCH_PLATFORM
environment:
DEV_CONTAINER: 1
secrets:
- gradle_properties
volumes:
- persistent:/persistent
env_file:
- docker/.env
- docker/.env.local
hostname: 'xtc-platform2.localhost.xqiz.it'
- .env.local
hostname: ${PLATFORM_HOSTNAME:-xtc-platform.local-dev.xqiz.it}
#extra_hosts:
# - "xtc-platform.localhost.xqiz.it:127.0.0.1"
# - "xtc-platform.xqiz.it:127.0.0.10"
Expand Down
4 changes: 0 additions & 4 deletions docker/.env

This file was deleted.

4 changes: 0 additions & 4 deletions docker/.env.local

This file was deleted.

35 changes: 10 additions & 25 deletions docker/Dockerfile.platform
Original file line number Diff line number Diff line change
@@ -1,39 +1,21 @@
#FROM openjdk:21
FROM ubuntu:24.04

ARG DOCKER_BUILDKIT=$DOCKER_BUILDKIT
ENV DOCKER_BUILD_KIT=$DOCKER_BUILDKIT
FROM openjdk:21-jdk-slim-bookworm

ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV DEBIAN_FRONTEND=noninteractive

ARG XTC_USER=xtc
ARG XTC_USER_HOME=/home/$XTC_USER
ARG NPM_SAFE_VERSION='[email protected]'
ARG GITHUB_BRANCH_XVM
ARG GITHUB_BRANCH_PLATFORM

ENV XTC_USER=$XTC_USER
ENV XTC_USER_HOME=$XTC_USER_HOME
ENV XQIZIT_HOME=$XTC_USER_HOME/xqiz.it
ENV PLATFORM_HOME=$XQIZIT_HOME/platform
ENV GITHUB_BRANCH_XVM=$GITHUB_BRANCH_XVM
ENV GITHUB_BRANCH_PLATFORM=$GITHUB_BRANCH_PLATFORM

USER root

RUN apt-get update && apt-get install --no-install-recommends -y \
iputils-ping jq sudo wget curl git openjdk-21-jdk

# Actually, we don't need a node installation. The Gradle plugin handles everything.
#RUN curl --silent --location https://deb.nodesource.com/setup_21.x | sudo bash -
#RUN apt-get -y --no-install-recommends install nodejs && npm -g install npm@${NPM_SAFE_VERSION} # && npm -g install yarn
iputils-ping jq sudo wget curl git emacs-nox

# Install dev tools. We should separate these out later.
RUN apt-get install --no-install-recommends -y emacs-nox

COPY *.sh /usr/local/bin
COPY docker/scripts/*.sh /usr/local/bin

RUN useradd -ms /bin/bash $XTC_USER \
&& passwd -d $XTC_USER \
Expand All @@ -44,11 +26,14 @@ RUN useradd -ms /bin/bash $XTC_USER \

USER $XTC_USER

# From README.md: Create xqiz.it subdirectory and config
RUN mkdir -p $PLATFORM_HOME && mkdir -p $XQIZIT_HOME/config
RUN mkdir -p $PLATFORM_HOME
RUN mkdir -p $XTC_USER_HOME/lib/xdk

# Copy the local build (todo could also bind mount it)
COPY build/platform/* $XTC_USER_HOME/lib
COPY build/xtc/xdk/lib/* $XTC_USER_HOME/lib/xdk

# From README.md: Create port forwarding config.
COPY config/port-forwarding.conf $PLATFORM_HOME
# We should probably use a real XDK,

# From README.md create: a self-signed certificate for the platform web server. For example:
ARG PLATFORM_PASSWORD
Expand Down
7 changes: 7 additions & 0 deletions docker/Dockerfile.platform.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM ghcr.io/xtclang/xdk-platform:latest as platform

ARG GITHUB_BRANCH_PLATFORM
ENV GITHUB_BRANCH_PLATFORM=$GITHUB_BRANCH_PLATFORM

USER root

3 changes: 3 additions & 0 deletions docker/cert/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This directory contains prebuild self signed certificates for the XTC Platform hostname, and with the
key store password 'password'. They should not be used in production, naturally. The dev container
generates these values itself.
5 changes: 5 additions & 0 deletions docker/config/cfg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"hostName": "xtc-platform.container.xqiz.it",
"httpPort": 8080,
"httpsPort": 8090
}
50 changes: 0 additions & 50 deletions docker/entrypoint.sh

This file was deleted.

Loading

0 comments on commit a003554

Please sign in to comment.