Skip to content

Commit

Permalink
Merge pull request UOX3DevTeam#164 from UOX3DevTeam/feature/docker-build
Browse files Browse the repository at this point in the history
Docker build (not run)
  • Loading branch information
strattond authored Jan 11, 2023
2 parents 8e82bb6 + 7abb658 commit 04cca74
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 1 deletion.
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
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM quay.io/centos/centos:stream AS buildbase
RUN yum -y install tar unzip glibc.i686 gcc dos2unix cmake gcc-c++ && yum clean all && rm -rf /var/cache/yum
RUN mkdir -p ~/uox3

FROM buildbase AS buildapp
WORKDIR /root/uox3
COPY . .
RUN find /root/uox3 -name \* -type f -exec dos2unix {} \;
RUN cd /root/uox3 && ./automake.sh
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/
COPY --chown=uox3 docker/run.sh .
RUN chmod 777 /home/uox3/app/run.sh && dos2unix /home/uox3/app/run.sh
CMD ["/home/uox3/app/run.sh"]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Join the [UOX3 Discord](https://discord.gg/uBAXxhF) for support and/or a quick c
> * **Linux (Debian-based)** - Run `sudo apt install build-essential cmake` in a Terminal: (or use your Linux distro's package manager)
> * **FreeBSD** - Run `pkg install cmake` in a Terminal. Alternatively, build `cmake` via ports if desired.
> * **macOS** - Download [Xcode](https://apps.apple.com/us/app/xcode/id497799835?mt=12) (for building with an IDE) via the App Store, and/or [CMake](https://cmake.org/download/) (for command-line builds)
> * **Docker/Podman** - Ensure that it is downloaded and installed (Windows) or installed from your package manager
</details>
<details>
Expand Down Expand Up @@ -157,6 +158,11 @@ Join the [UOX3 Discord](https://discord.gg/uBAXxhF) for support and/or a quick c
</details>
</details>
<details>
<summary><strong>Docker/Podman</strong></summary>

Build and tag the image from the root of the repository like: `docker buildx build --progress=plain -t uox3 .` or `podman build -t uox3 .`
</details>

---
## UOX3 Compiled! Now what?
Expand Down
2 changes: 1 addition & 1 deletion automake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ else
echo "uox3 program not found! Please review the build status."
cd ../../..
fi
fi
fi
1 change: 1 addition & 0 deletions docker/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sh text eol=lf
3 changes: 3 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
cd ~/app
./uox3 data/uox.ini
1 change: 1 addition & 0 deletions make/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ target_link_libraries(uox3 PRIVATE
$<$<PLATFORM_ID:Windows>:Kernel32>
$<$<PLATFORM_ID:Linux>:pthread>
$<$<PLATFORM_ID:FreeBSD>:pthread>
$<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,9.0>>:stdc++fs>
)

# *************************************************************************
Expand Down
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 -Wall -Wextra -Wno-attributes
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 04cca74

Please sign in to comment.