From 1833d046383c5308ec7e02253d23a0c0ca4ca6bb Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Thu, 10 Aug 2023 17:51:14 +0100 Subject: [PATCH] Added source build --- beta/alpine-beta/docker-compose.yml | 7 ++- beta/source/Dockerfile | 29 +++++++++ beta/source/defaults/OpenSim.ini | 39 ++++++++++++ beta/source/defaults/SQLiteStandalone.ini | 39 ++++++++++++ beta/source/defaults/StandaloneCommon.ini | 43 +++++++++++++ beta/source/docker-compose.yml | 36 +++++++++++ beta/source/docker-entrypoint.sh | 73 +++++++++++++++++++++++ 7 files changed, 265 insertions(+), 1 deletion(-) create mode 100644 beta/source/Dockerfile create mode 100644 beta/source/defaults/OpenSim.ini create mode 100644 beta/source/defaults/SQLiteStandalone.ini create mode 100644 beta/source/defaults/StandaloneCommon.ini create mode 100644 beta/source/docker-compose.yml create mode 100755 beta/source/docker-entrypoint.sh diff --git a/beta/alpine-beta/docker-compose.yml b/beta/alpine-beta/docker-compose.yml index 3f170fb..776cb11 100644 --- a/beta/alpine-beta/docker-compose.yml +++ b/beta/alpine-beta/docker-compose.yml @@ -2,6 +2,10 @@ version: '3.6' services: db: image: docker.io/library/mariadb:10.5 + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] + timeout: 20s + retries: 5 volumes: - "database_store:/var/lib/mysql" environment: @@ -11,7 +15,8 @@ services: build: context: . depends_on: - - db + db: + condition: service_healthy ports: - "9000:9000" - "9000:9000/udp" diff --git a/beta/source/Dockerfile b/beta/source/Dockerfile new file mode 100644 index 0000000..d7843c7 --- /dev/null +++ b/beta/source/Dockerfile @@ -0,0 +1,29 @@ +FROM mcr.microsoft.com/dotnet/sdk:6.0 as build + +RUN git clone git://opensimulator.org/git/opensim /app +WORKDIR /app +RUN git checkout dotnet6 + +RUN ./runprebuild.sh && ./compile.sh + +FROM mcr.microsoft.com/dotnet/runtime:6.0 + +LABEL org.opencontainers.image.title="OpenSimulator (unofficial)" +LABEL org.opencontainers.image.authors="code@soupbowl.io" +LABEL org.opencontainers.image.source="https://github.com/soup-bowl/opensimulator-docker" +LABEL org.opencontainers.image.licenses="MIT" + +RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev screen uuid-runtime + +COPY --from=build /app /opt/opensim + +COPY defaults /opt/opensim/bin/defaults + +EXPOSE 9000 + +WORKDIR /opt/opensim/bin + +COPY docker-entrypoint.sh /usr/local/bin/ + +ENTRYPOINT ["docker-entrypoint.sh"] +CMD [ "screen", "-S", "OpenSim", "-D", "-m", "sh", "./opensim.sh" ] diff --git a/beta/source/defaults/OpenSim.ini b/beta/source/defaults/OpenSim.ini new file mode 100644 index 0000000..06e02e1 --- /dev/null +++ b/beta/source/defaults/OpenSim.ini @@ -0,0 +1,39 @@ + +[Const] + BaseHostname = "localhost" + BaseURL = http://${Const|BaseHostname} + PublicPort = "9000" + PrivURL = ${Const|BaseURL} + PrivatePort = "8003" + +[Permissions] + automatic_gods = false + implicit_gods = false + allow_grid_gods = true + +[Network] + http_listener_port = 9000 + ExternalHostNameForLSL = ${Const|BaseHostname} + shard = "OpenSim" + +[ClientStack.LindenCaps] + Cap_GetTexture = "localhost" + Cap_GetMesh = "localhost" + Cap_AvatarPickerSearch = "localhost" + Cap_GetDisplayNames = "localhost" + +[BulletSim] + AvatarToAvatarCollisionsByDefault = true + +[XEngine] + AppDomainLoading = false + DeleteScriptsOnStartup = false + +[OSSL] + Include-osslDefaultEnable = "config-include/osslDefaultEnable.ini" + +[Architecture] + Include-Architecture = "config-include/Standalone.ini" + +[WebStats] + enabled = true diff --git a/beta/source/defaults/SQLiteStandalone.ini b/beta/source/defaults/SQLiteStandalone.ini new file mode 100644 index 0000000..200a9c9 --- /dev/null +++ b/beta/source/defaults/SQLiteStandalone.ini @@ -0,0 +1,39 @@ +; These are the initialization settings for running OpenSim Standalone with an SQLite database + +[DatabaseService] + StorageProvider = "OpenSim.Data.SQLite.dll" + ConnectionString = "URI=file:sqlite-database/OpenSim.db,version=3,UseUTF16Encoding=True" + +[AssetService] + ConnectionString = "URI=file:sqlite-database/Asset.db,version=3" + +; The HGAssetService section controls the connection given to the AssetService in a Hypergrid configuration. +; This has to be separate from [AssetService] because the Hypergrid facing connector uses [HGAssetService] for its config data instead. +; However, the internal asset service will still use the [AssetService] section. +; Therefore, you will almost certainly want the ConnectionString in [HGAssetService] to be the same as in [AssetService] +; so that they both access the same database. +; This issue does not apply to normal MySQL/MSSQL configurations, since by default they use the settings in [DatabaseService] and +; do not have separate connection strings for different services. +[HGAssetService] + ConnectionString = "URI=file:sqlite-database/Asset.db,version=3" + +[InventoryService] + ;ConnectionString = "URI=file:inventory.db,version=3" + ; if you have a legacy inventory store use the connection string below + ConnectionString = "URI=file:sqlite-database/inventory.db,version=3,UseUTF16Encoding=True" + +[AvatarService] + ConnectionString = "URI=file:sqlite-database/avatars.db,version=3" + +[AuthenticationService] + ConnectionString = "URI=file:sqlite-database/auth.db,version=3" + +[UserAccountService] + ConnectionString = "URI=file:sqlite-database/userprofiles.db,version=3" + +[GridUserService] + ConnectionString = "URI=file:sqlite-database/griduser.db,version=3" + +[FriendsService] + ConnectionString = "URI=file:sqlite-database/friends.db,version=3" + diff --git a/beta/source/defaults/StandaloneCommon.ini b/beta/source/defaults/StandaloneCommon.ini new file mode 100644 index 0000000..b9e9fc5 --- /dev/null +++ b/beta/source/defaults/StandaloneCommon.ini @@ -0,0 +1,43 @@ +; This is the main configuration file for an instance of OpenSim running in standalone mode + +[Hypergrid] + HomeURI = "${Const|BaseURL}:${Const|PublicPort}" + +[Modules] + AssetCaching = "FlotsamAssetCache" + Include-FlotsamCache = "config-include/FlotsamCache.ini" + +[AssetService] + DefaultAssetLoader = "OpenSim.Framework.AssetLoader.Filesystem.dll" + AssetLoaderArgs = "assets/AssetSets.xml" + +[LibraryModule] + LibraryName = "Library" + +[LoginService] + WelcomeMessage = "OpenSimulator is running!" + SRV_HomeURI = "${Hypergrid|HomeURI}" + SRV_InventoryServerURI = "${Const|BaseURL}:${Const|PublicPort}" + SRV_AssetServerURI = "${Const|BaseURL}:${Const|PublicPort}" + SRV_ProfileServerURI = "${Const|BaseURL}:${Const|PublicPort}" + SRV_FriendsServerURI = "${Const|BaseURL}:${Const|PublicPort}" + SRV_IMServerURI = "${Const|BaseURL}:${Const|PublicPort}" + MapTileURL = "${Const|BaseURL}:${Const|PublicPort}/" + +[GridInfoService] + login = ${Const|BaseURL}:${Const|PublicPort}/ + gridname = "OpenSimulator Instance" + gridnick = "osss" + welcome = ${Const|BaseURL}:8080 + +[GatekeeperService] + AllowTeleportsToAnyRegion = true + +[EntityTransfer] + AccountForAppearance = "Test User, Astronaut Smith" + +[UserProfilesService] + Enabled = false + LocalServiceModule = "OpenSim.Services.UserProfilesService.dll:UserProfilesService" + UserAccountService = OpenSim.Services.UserAccountService.dll:UserAccountService + AuthenticationServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" diff --git a/beta/source/docker-compose.yml b/beta/source/docker-compose.yml new file mode 100644 index 0000000..14eef45 --- /dev/null +++ b/beta/source/docker-compose.yml @@ -0,0 +1,36 @@ +version: '3.6' +services: + db: + image: docker.io/library/mariadb:10.5 + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] + timeout: 20s + retries: 5 + volumes: + - "database_store:/var/lib/mysql" + environment: + MYSQL_DATABASE: metaverse + MYSQL_ROOT_PASSWORD: password + metaverse: + container_name: opensim + build: + context: . + depends_on: + db: + condition: service_healthy + stdin_open: true + tty: true + ports: + - "9000:9000" + - "9000:9000/udp" + environment: + DATABASE_ENGINE: mysql + MYSQL_SERVER: db + MYSQL_DATABASE: metaverse + MYSQL_USER: root + MYSQL_PASSWORD: password + ESTATE_OWNER_NAME: Governor Linden + ESTATE_OWNER_PASSWORD: password + +volumes: + database_store: diff --git a/beta/source/docker-entrypoint.sh b/beta/source/docker-entrypoint.sh new file mode 100755 index 0000000..f6749fd --- /dev/null +++ b/beta/source/docker-entrypoint.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +set -Eeo pipefail + +chown -R $(id -u):$(id -g) defaults + +if [ ! -e OpenSim.ini ]; then + echo >&2 "INFO: No OpenSim configuration found, pulling one together." + cp defaults/OpenSim.ini OpenSim.ini + + echo -e "\n[Estates] + DefaultEstateName = ${ESTATE_NAME:-Default Estate} + DefaultEstateOwnerName = ${ESTATE_OWNER_NAME:-Foo Bar} + DefaultEstateOwnerUUID = ${ESTATE_OWNER_UUID:-00000000-0000-0000-0000-000000000000} + DefaultEstateOwnerEMail = ${ESTATE_OWNER_EMAIL:-user@example.com} + DefaultEstateOwnerPassword = ${ESTATE_OWNER_PASSWORD:-password}" >> OpenSim.ini + + if [[ "${DATABASE_ENGINE}" == "mysql" ]]; then + echo -e "\n[Messaging] + StorageProvider = \"OpenSim.Data.MySQL.dll\" + ConectionString = \"Data Source=${MYSQL_SERVER:-db};Database=${MYSQL_DATABASE:-opensim};User ID=${MYSQL_USER:-root};Password=${MYSQL_PASSWORD};Old Guids=true;\"" >> OpenSim.ini + fi +else + echo >&2 "INFO: OpenSimulator general configuration found. Skipping..." +fi + +if [ ! -e config-include/StandaloneCommon.ini ] || [ ! -e config-include/GridCommon.ini ]; then + echo >&2 "INFO: No Grid Common configuration found, pulling one together." + cp defaults/StandaloneCommon.ini config-include/StandaloneCommon.ini + + echo "[DatabaseService]" >> config-include/StandaloneCommon.ini + if [[ "${DATABASE_ENGINE}" == "mysql" ]]; then + echo " StorageProvider = \"OpenSim.Data.MySQL.dll\"" >> config-include/StandaloneCommon.ini + echo " ConnectionString = \"Data Source=${MYSQL_SERVER:-db};Database=${MYSQL_DATABASE:-opensim};User ID=${MYSQL_USER:-root};Password=${MYSQL_PASSWORD};Old Guids=true;\"" >> config-include/StandaloneCommon.ini + else + echo " Include-Storage = \"config-include/storage/SQLiteStandalone.ini\"" >> config-include/StandaloneCommon.ini + fi + + echo "[GridService] + StorageProvider = \"OpenSim.Data.Null.dll:NullRegionData\" + Region_${REGION_NAME:-Region} = \"DefaultRegion, FallbackRegion\" + ExportSupported = true" >> config-include/StandaloneCommon.ini + + if [ -n "${GRID_WELCOME}" ]; then + sed -i -e "s/OpenSimulator is running!/${GRID_WELCOME}/g" config-include/StandaloneCommon.ini + fi + + if [ -n "${GRID_NAME}" ]; then + sed -i -e "s/OpenSimulator Instance/${GRID_NAME}/g" config-include/StandaloneCommon.ini + fi +else + echo >&2 "INFO: Standalone or Grid configuration found. Skipping..." +fi + +if [ `find Regions -maxdepth 1 -name '*.ini' | wc -l` -eq 0 ]; then + echo >&2 "INFO: No region details found, pulling one together." + + echo "[${REGION_NAME:-Region}] + RegionUUID = $(uuidgen) + Location = ${REGION_LOCATION:-1000,1000} + InternalAddress = 0.0.0.0 + InternalPort = 9000 + AllowAlternatePorts = False + ExternalHostName = ${REGION_EXTERNAL_HOSTNAME:-localhost}" >> Regions/Regions.ini +else + echo >&2 "INFO: Looks like there's region definitions. Skipping..." +fi + +if [ ! -e config-include/storage/SQLiteStandalone.ini ]; then + cp defaults/SQLiteStandalone.ini config-include/storage/SQLiteStandalone.ini + mkdir -p sqlite-database +fi + +exec "$@"