mirror of
https://github.com/Misterblue/opensim-docker.git
synced 2026-07-30 11:22:14 +00:00
* ISSUE-17: fixes obsolete "version" attribute inside docker-compose.yml files * added .gitignore with some general basic settings * dockerfiles fixes - fixes missing permissions for .sh files inside the images - fixes COPY of multiple files (missing trailing slash '/' on target path - fixes use of hardcoded username:usergroup on COPY --chown * dockerfiles fixes - fixes COPY of multiple files (missing trailing slash '/' on target path * fixes missing OS_CONFIGKEY on setEnvironment.sh files --------- Co-authored-by: Lordfox <c.haendler@lordfox.de>
145 lines
5.3 KiB
Plaintext
145 lines
5.3 KiB
Plaintext
# syntax=docker/dockerfile:1
|
|
# OpenSim for a container
|
|
# docker build -t opensim .
|
|
|
|
# Built with dotnet8
|
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
|
|
|
LABEL Description="Docker container running OpenSim"
|
|
|
|
# In the target image, these are directories built and used
|
|
# While parameters, these usually don't change
|
|
ARG OPENSIMHOME=/home/opensim
|
|
ARG OPENSIMDIR=/home/opensim/opensim
|
|
ARG OPENSIMCONFIG=/home/opensim/opensim/bin/config
|
|
ARG VERSIONDIR=/home/opensim/VERSION
|
|
ARG OS_ACCOUNT=opensim
|
|
|
|
# Arguments for fetching the proper version of OpenSimulator
|
|
ARG OS_GIT_REPO=git://opensimulator.org/git/opensim
|
|
ARG OS_GIT_BRANCH=master
|
|
ARG OS_BUILDTARGET=Release
|
|
ARG OS_SLN=OpenSim.sln
|
|
|
|
# Arguments about the build environment passed in so they can be embedded in the container
|
|
ARG BUILD_DATE=20240101.0000
|
|
ARG BUILD_DAY=20240101
|
|
ARG OS_DOCKER_VERSION=1.0.0
|
|
ARG OS_DOCKER_GIT_BRANCH=main
|
|
ARG OS_DOCKER_GIT_COMMIT=62fda19d0038a274bf3fd922b023b149b3a40a90
|
|
ARG OS_DOCKER_GIT_COMMIT_SHORT=62fda19d
|
|
|
|
# Include required packages ('coreutils git vim' included for debugging)
|
|
RUN apt-get update \
|
|
&& apt-get install -y \
|
|
coreutils procps git vim \
|
|
screen \
|
|
ccrypt \
|
|
libgdiplus \
|
|
libc6-dev \
|
|
mariadb-client
|
|
|
|
# The simulator is run under the user name 'opensim'
|
|
RUN adduser --disabled-password --gecos 'OpenSimulator user' $OS_ACCOUNT
|
|
|
|
USER $OS_ACCOUNT:$OS_ACCOUNT
|
|
|
|
# Version information that goes in the image
|
|
RUN mkdir -p $VERSIONDIR \
|
|
&& cd $VERSIONDIR \
|
|
&& echo $BUILD_DATE > "BUILD_DATE" \
|
|
&& echo $BUILD_DAY > "BUILD_DAY" \
|
|
&& echo $OS_DOCKER_VERSION > "OS_DOCKER_VERSION" \
|
|
&& echo $OS_DOCKER_GIT_BRANCH > "OS_DOCKER_GIT_BRANCH" \
|
|
&& echo $OS_DOCKER_GIT_COMMIT > "OS_DOCKER_GIT_COMMIT" \
|
|
&& echo $OS_DOCKER_GIT_COMMIT_SHORT > "OS_DOCKER_GIT_COMMIT_SHORT" \
|
|
&& echo ${OS_DOCKER_VERSION}-${BUILD_DAY}-${OS_DOCKER_GIT_COMMIT_SHORT} > "OS_DOCKER_IMAGE_VERSION"
|
|
|
|
# Fetch the latest version of the OpenSimulator sources.
|
|
RUN cd $OPENSIMHOME \
|
|
&& git clone --depth=1 -b $OS_GIT_BRANCH --single-branch $OS_GIT_REPO opensim
|
|
|
|
# Extract version information from the fetched sources
|
|
RUN cd $OPENSIMDIR \
|
|
&& echo $OS_GIT_REPO > "$VERSIONDIR/OS_GIT_REPO" \
|
|
&& echo $OS_GIT_BRANCH > "$VERSIONDIR/OS_GIT_BRANCH" \
|
|
&& echo $OS_BUILDTARGET > "$VERSIONDIR/OS_BUILD_TARGET" \
|
|
&& git describe --tags --long --always > "$VERSIONDIR/OS_GIT_DESCRIBE" \
|
|
&& git rev-parse HEAD > "$VERSIONDIR/OS_GIT_COMMIT" \
|
|
&& git rev-parse --short HEAD > "$VERSIONDIR/OS_GIT_COMMIT_SHORT" \
|
|
&& grep "const string VersionNumber" ./OpenSim/Framework/VersionInfo.cs | \
|
|
sed -e "s/^.*VersionNumber = \"\(.*\)\".*$/\1/" > "$VERSIONDIR/OS_VERSION"
|
|
|
|
|
|
# Build OpenSimulator
|
|
RUN cd $OPENSIMDIR \
|
|
&& chmod +x runprebuild.sh \
|
|
&& ./runprebuild.sh \
|
|
&& dotnet build --configuration $OS_BUILDTARGET $OS_SLN
|
|
|
|
# None of the configuration files in the built image are used
|
|
# Configuration files are all specified by invocation parameter.
|
|
|
|
# =======================================================================
|
|
# Create the binary only container with the dotnet8 runtime
|
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS release
|
|
|
|
# In the target image, these are directories built and used
|
|
ARG OPENSIMHOME=/home/opensim
|
|
ARG OPENSIMDIR=/home/opensim/opensim
|
|
ARG VERSIONDIR=/home/opensim/VERSION
|
|
ARG OS_BUILDTARGET=Release
|
|
ARG OS_ACCOUNT=opensim
|
|
|
|
# Include required packages ('coreutils,git,vim' included for debugging)
|
|
RUN apt-get update \
|
|
&& apt-get install -y \
|
|
coreutils procps git vim \
|
|
screen \
|
|
ccrypt \
|
|
cron \
|
|
libgdiplus \
|
|
libc6-dev \
|
|
mariadb-client \
|
|
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
|
|
|
|
# The simulator is run under the user name 'opensim'
|
|
RUN adduser --disabled-password --gecos 'OpenSimulator user' $OS_ACCOUNT
|
|
|
|
USER $OS_ACCOUNT:$OS_ACCOUNT
|
|
|
|
# Scripts that keep OpenSimulator running, make crash reports, clean up log files, etc
|
|
COPY --chown=$OS_ACCOUNT:$OS_ACCOUNT temp-run-scripts/*.sh $OPENSIMHOME/
|
|
COPY --chown=$OS_ACCOUNT:$OS_ACCOUNT temp-run-scripts/crontab $OPENSIMHOME
|
|
COPY --chown=$OS_ACCOUNT:$OS_ACCOUNT temp-run-scripts/vimrc $OPENSIMHOME/.vimrc
|
|
|
|
# Copy the binary files
|
|
COPY --from=build --chown=$OS_ACCOUNT:$OS_ACCOUNT $OPENSIMDIR/bin $OPENSIMDIR/bin
|
|
COPY --from=build --chown=$OS_ACCOUNT:$OS_ACCOUNT $VERSIONDIR $VERSIONDIR
|
|
|
|
# The .ini files in config-include in the image are not used and are emptied here to eliminate any confusion
|
|
RUN cd $OPENSIMDIR/bin/config-include \
|
|
&& chmod +x $OPENSIMHOME/*.sh \
|
|
&& $OPENSIMHOME/nullOutConfigInclude.sh
|
|
|
|
# Create the directory that is mounted that includes all the configuration
|
|
RUN mkdir -p $OPENSIMDIR/bin/config
|
|
|
|
WORKDIR $OPENSIMDIR/bin
|
|
ENTRYPOINT [ "/home/opensim/bootOpenSim.sh" ]
|
|
|
|
# No ports are exposed by default since the simulator and regions can be anywhere.
|
|
# The simulator defaults to port 9000.
|
|
# EXPOSE 9000/tcp
|
|
# EXPOSE 9000/udp
|
|
|
|
# Directories that can be overridden with a mounted volume for configuration.
|
|
# The default configuration is for a simple standalone region.
|
|
# All the normal configuration has been nulled out (OpenSim.ini is the default
|
|
# and all the included files in bin/config-include are empty).
|
|
# A non-standalone configuration replaces bin/config with files that do
|
|
# the configuration of the whole system (include 'architecture' ini file and
|
|
# the necessary other INI files).
|
|
VOLUME $OPENSIMDIR/bin/config
|
|
|