Skip to content

Commit

Permalink
Add docker ignore file for irrelevancy. Add multi-stage docker build …
Browse files Browse the repository at this point in the history
…process. Tweak automake script to allow for running parts of it. Tweak Makefile to include c++fs for GCC <= 8
  • Loading branch information
strattondrs committed Nov 9, 2022
1 parent 028f4c9 commit a13ffa5
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 51 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Dockerfile*
.git
.github
vs2022
54 changes: 54 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#syntax = docker/dockerfile:1.4.0

FROM quay.io/centos/centos:stream AS buildbase
#RUN yum -y install tar unzip wget glibc.i686 which sudo gcc net-tools dos2unix make gcc-c++ && yum clean all && rm -rf /var/cache/yum
RUN yum -y install tar unzip glibc.i686 gcc dos2unix make gcc-c++ && yum clean all && rm -rf /var/cache/yum
RUN mkdir -p ~/uox3

FROM buildbase AS buildjs
#COPY automakejs.sh /root/uox3
COPY automake.sh /root/uox3
COPY spidermonkey /root/uox3/spidermonkey/
RUN find /root/uox3 -name \* -type f -exec dos2unix {} \;
#RUN cd /root/uox3 && ./automakejs.sh
RUN cd /root/uox3 && ./automake.sh 1
CMD ["/bin/bash"]

FROM buildbase AS buildzlib
#COPY automakezlib.sh /root/uox3
COPY automake.sh /root/uox3
COPY zlib /root/uox3/zlib/
RUN find /root/uox3 -name \* -type f -exec dos2unix {} \;
#RUN cd /root/uox3 && ./automakezlib.sh
RUN cd /root/uox3 && ./automake.sh 2
CMD ["/bin/bash"]

FROM buildbase AS buildapp
WORKDIR /root/uox3
RUN mkdir -p spidermonkey && mkdir -p zlib
#COPY automakeuox3.sh .
COPY automake.sh .
COPY source source/
RUN find /root/uox3 -name \* -type f -exec dos2unix {} \;
COPY --from=buildjs /root/uox3/spidermonkey spidermonkey/
COPY --from=buildzlib /root/uox3/zlib zlib/
#RUN cd /root/uox3 && ./automakeuox3.sh
RUN cd /root/uox3 && ./automake.sh 3
CMD ["/bin/bash"]

FROM quay.io/centos/centos:stream
RUN yum -y install glibc.i686 dos2unix && yum clean all && rm -rf /var/cache/yum
RUN adduser --system --create-home uox3
USER uox3
RUN mkdir -p ~/app
WORKDIR /home/uox3/app
COPY --from=buildapp --chown=uox3 /root/uox3/uox3 .
COPY --chown=uox3 data data/
COPY --chown=uox3 docs docs/
RUN <<EOF cat >> ~/app/run.sh
#!/usr/bin/env bash
cd ~/app
./uox3 data/uox.ini
EOF
RUN chmod 777 ~/app/run.sh && dos2unix ~/app/run.sh
CMD ["~/app/run.sh"]
118 changes: 67 additions & 51 deletions automake.sh
Original file line number Diff line number Diff line change
@@ -1,61 +1,77 @@
#!/usr/bin/env bash
echo "Building spidermonkey"
cd spidermonkey
if [ "$(uname)" = "FreeBSD" ]
then
gmake -f Makefile.ref DEFINES=-DHAVE_VA_LIST_AS_ARRAY CC=clang
if (( $# == 0 )); then
# No parameters, all stages
stage=0
else
make -f Makefile.ref DEFINES=-DHAVE_VA_LIST_AS_ARRAY CC=gcc
stage="$1"
fi

$ev=$?
if [ $ev -ne 0 ]; then
echo "Unable to build spidermonkey, cannot continue"
exit $ev
if [ $stage -eq 0 ] || [ $stage -eq 1 ]; then
echo "Building spidermonkey"
cd spidermonkey
if [ "$(uname)" = "FreeBSD" ]
then
gmake -f Makefile.ref DEFINES=-DHAVE_VA_LIST_AS_ARRAY CC=clang
else
make -f Makefile.ref DEFINES=-DHAVE_VA_LIST_AS_ARRAY CC=gcc
fi

ev=$?
if [ $ev -ne 0 ]; then
echo "Unable to build spidermonkey, cannot continue"
exit $ev
fi
if [ "$(uname)" = "Darwin" ]
then
# Mac OS X
ar rcs libjs32.a Darwin_DBG.OBJ/*.o
cp Darwin_DBG.OBJ/jsautocfg.h ./
elif [ "$(uname)" = "FreeBSD" ]
then
ar rcs libjs32.a FreeBSD_DBG.OBJ/*.o
cp FreeBSD_DBG.OBJ/jsautocfg.h ./
elif [ "$(expr substr $(uname -s) 1 5)" = "Linux" ]
then
# Linux
ar -r libjs32.a Linux_All_DBG.OBJ/*.o
cp Linux_All_DBG.OBJ/jsautocfg.h ./
fi
cd ..
if [ $stage -eq 1 ]; then exit 0; fi
fi

if [ "$(uname)" = "Darwin" ]
then
# Mac OS X
ar rcs libjs32.a Darwin_DBG.OBJ/*.o
cp Darwin_DBG.OBJ/jsautocfg.h ./
elif [ "$(uname)" = "FreeBSD" ]
then
ar rcs libjs32.a FreeBSD_DBG.OBJ/*.o
cp FreeBSD_DBG.OBJ/jsautocfg.h ./
elif [ "$(expr substr $(uname -s) 1 5)" = "Linux" ]
then
# Linux
ar -r libjs32.a Linux_All_DBG.OBJ/*.o
cp Linux_All_DBG.OBJ/jsautocfg.h ./
if [ $stage -eq 0 ] || [ $stage -eq 2 ]; then
cd zlib
echo "Bulding zlib"
make distclean
./configure
make
ev=$?
if [ $ev -ne 0 ]; then
echo "Unable to build zlib, cannot continue"
exit $ev
fi
cd ..
if [ $stage -eq 2 ]; then exit 0; fi
fi

cd ../zlib
echo "Bulding zlib"
make distclean
./configure
make

$ev=$?
if [ $ev -ne 0 ]; then
echo "Unable to build zlib, cannot continue"
if [ $stage -eq 0 ] || [ $stage -eq 3 ]; then
cd source
echo "Building UOX3"
if [ "$(uname)" = "FreeBSD" ]
then
gmake
else
make
fi
ev=$?
if [ -f ./uox3 ]; then
cp uox3 ..
echo "Done! You should now find the compiled uox3 binary in the root UOX3 project directory. Copy this binary to a separate directory dedicated to running your UOX3 shard, along with the contents of the UOX3/data directory, to avoid potential git conflicts and accidental overwriting of data when pulling UOX3 updates in the future."
else
echo "uox3 output not created! Please review compile status"
fi
cd ..
exit $ev
fi

cd ../source
echo "Building UOX3"
if [ "$(uname)" = "FreeBSD" ]
then
gmake
else
make
fi
ev=$?
if [ -f ./uox3 ]; then
cp uox3 ..
echo "Done! You should now find the compiled uox3 binary in the root UOX3 project directory. Copy this binary to a separate directory dedicated to running your UOX3 shard, along with the contents of the UOX3/data directory, to avoid potential git conflicts and accidental overwriting of data when pulling UOX3 updates in the future."
else
echo "uox3 output not created! Please review compile status"
fi
cd ..
exit $ev
5 changes: 5 additions & 0 deletions source/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ifeq ($(PLATFORM),FreeBSD)
CXX := clang++
else
CXX := g++
GCCVER8 := $(shell expr `gcc -dumpversion | cut -f1 -d.` \<= 8)
endif

CXXFLAGS := -std=c++17 -O2 -pthread -Wno-shift-negative-value
Expand All @@ -22,6 +23,10 @@ BUILD := ./build
SRC := $(wildcard *.cpp)
OBJECTS := $(SRC:%.cpp=$(BUILD)/%.o)

ifeq "$(GCCVER8)" "1"
LDFLAGS += -lstdc++fs
endif

#COMPILE := $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(INCLUDE) -c

all: build $(TARGET)
Expand Down

0 comments on commit a13ffa5

Please sign in to comment.