Skip to content

Commit a63201b

Browse files
authored
Merge pull request #22 from amylizzle/downloadinstead
Download releases instead
2 parents d2e19c9 + eced3c5 commit a63201b

File tree

9 files changed

+128
-51
lines changed

9 files changed

+128
-51
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
workflow_dispatch:
44
pull_request:
55
branches:
6-
- master
6+
- main
77
push:
88

99
jobs:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
1. Python 3.11
66
2. Poetry (Recommended)
77
3. Docker (**Strongly** recommended that this is ran in rootless mode)
8-
4. ~10GB of disk space
8+
4. ~1GB of disk space
99

1010
## About:
1111

docker/Dockerfile

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS builder
1+
FROM mcr.microsoft.com/dotnet/runtime:9.0-alpine AS builder
2+
3+
4+
RUN adduser odcompile -H -D
5+
RUN apk add libsodium-dev
26

37
WORKDIR /opendream
48

59
COPY ./OpenDream/ .
610

7-
ARG BULD_CONFIG=Release
8-
9-
RUN dotnet build OpenDreamServer --configuration ${BULD_CONFIG} && \
10-
dotnet build DMCompiler --configuration ${BULD_CONFIG} && \
11-
ln -s /opendream/bin/DMCompiler/DMCompiler /usr/bin/ && \
12-
ln -s /opendream/bin/Content.Server/OpenDreamServer /usr/bin
11+
RUN ln -s /opendream/DMCompiler_linux-x64/ /opendream/compiler
12+
RUN ln -s /opendream/OpenDreamServer_linux-x64/ /opendream/server
1313

1414
FROM builder
1515

1616
WORKDIR /app
1717

1818
COPY docker/run.sh .
1919

20-
RUN adduser odcompile -H -D && \
21-
chown -R odcompile: /app && \
22-
chown -R odcompile: /opendream/bin
20+
RUN chown -R odcompile: /opendream
21+
RUN chown -R odcompile: /app
2322

2423
USER odcompile
2524

docker/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ cp /app/code/* .
33
echo "---Preamble---"
44
echo Included compiler arguments: "$@"
55
echo "---Start Compiler---"
6-
DMCompiler "$@" test.dme
6+
dotnet exec /opendream/compiler/DMCompiler.dll "$@" test.dme
77
echo "---End Compiler---"
88
echo "---Start Server---"
9-
OpenDreamServer --config-file server_config.toml --cvar opendream.json_path=/app/test.json
9+
dotnet exec /opendream/server/Robust.Server.dll --config-file server_config.toml --cvar opendream.json_path=/app/test.json
1010
echo "---End Server---"

poetry.lock

Lines changed: 68 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ flask = "^2.3"
1515
docker = "^6.0"
1616
gitpython = "^3.1"
1717
gunicorn = "^20.1"
18+
wget = "^3.2"
1819

1920
[tool.poetry.group.dev.dependencies]
2021
flake8 = "^6.0"

src/od_compiler/util/docker_actions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ def updateBuildImage(build_config: str) -> None:
2222
"""
2323
od_path = Path.cwd().joinpath("OpenDream")
2424
try:
25-
updateOD(od_repo_path=od_path)
25+
updateOD(od_path=od_path)
2626
except BadName:
2727
compile_logger.warning("There was an error updating the repo. Cleaning up and trying again.")
28-
updateOD(od_repo_path=od_path, clean=True)
28+
updateOD(od_path=od_path, clean=True)
2929

3030
compile_logger.info("Building the docker image...")
3131
client.images.build(
Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,53 @@
1+
import os
2+
import tarfile
13
from pathlib import Path
24

3-
from git.repo import Repo
5+
import git
6+
import wget
47
from od_compiler.util.compiler_logger import compile_logger
58

69

7-
def updateOD(od_repo_path: Path, clean: int = False) -> None:
10+
def updateOD(od_path: Path, clean: int = False) -> None:
811
"""
912
Update the OpenDream repository if it exists. If it doesn't, clone a fresh copy.
1013
"""
11-
if clean:
12-
from shutil import rmtree
13-
14-
rmtree(od_repo_path)
15-
16-
if Path.exists(od_repo_path):
17-
od = Repo(od_repo_path)
18-
od.remote().fetch()
19-
# We reset HEAD to the upstream commit as a faster and more reliable way to stay up to date
20-
od.head.reset(commit="origin/master", working_tree=True)
21-
else:
22-
compile_logger.info("Repo not found. Cloning from GitHub.")
23-
od = Repo.clone_from(
24-
url="https://github.com/OpenDreamProject/OpenDream.git",
25-
to_path=od_repo_path,
26-
multi_options=["--depth 1", "--recurse-submodules", "--shallow-submodules"],
27-
)
28-
29-
compile_logger.info(f"The OpenDream repo is at: {od.head.commit.hexsha}")
30-
updateSubmodules(od_repo=od)
3114

15+
compiler_path = od_path / "compiler.tar.gz"
16+
server_path = od_path / "server.tar.gz"
17+
tag_path = od_path / "tag"
3218

33-
def updateSubmodules(od_repo: Repo) -> None:
34-
"""
35-
Recursively update and initialize submodules
19+
if clean:
20+
from shutil import rmtree
3621

37-
od_repo: OpenDream repository with the submodules
38-
"""
39-
for submodule in od_repo.submodules:
40-
submodule.update(init=True, recursive=True)
41-
compile_logger.info(f"{submodule.name} is at: {submodule.hexsha}")
22+
rmtree(od_path)
23+
24+
if not Path.exists(od_path):
25+
os.mkdir(od_path)
26+
remote_heads = git.cmd.Git().ls_remote("https://github.com/OpenDreamProject/OpenDream/", heads=True)
27+
tag_path.touch(exist_ok=True)
28+
with open(str(tag_path), "r+") as tag:
29+
if tag.readline() == remote_heads:
30+
compile_logger.info("OpenDream is already up to date.")
31+
return
32+
else:
33+
tag.seek(0)
34+
tag.write(remote_heads)
35+
36+
if compiler_path.exists():
37+
os.remove(compiler_path)
38+
if server_path.exists():
39+
os.remove(server_path)
40+
wget.download(
41+
"https://github.com/OpenDreamProject/OpenDream/releases/download/latest/DMCompiler_linux-x64.tar.gz",
42+
str(compiler_path),
43+
)
44+
wget.download(
45+
"https://github.com/OpenDreamProject/OpenDream/releases/download/latest/OpenDreamServer_linux-x64.tar.gz",
46+
str(server_path),
47+
)
48+
49+
with tarfile.open(str(compiler_path), "r:gz") as tar:
50+
tar.extractall(path=od_path)
51+
with tarfile.open(str(server_path), "r:gz") as tar:
52+
tar.extractall(path=od_path)
53+
compile_logger.info(f"The OpenDream repo is at: {remote_heads}")

tests/git_actions/test_git.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44

55
def test_update_repo_clean(od_repo_path):
6-
updateOD(od_repo_path=od_repo_path, clean=True)
6+
updateOD(od_path=od_repo_path, clean=True)
77

88

99
@pytest.mark.depends(on=["test_update_repo_clean"])
1010
def test_update_repo_existing(od_repo_path):
11-
updateOD(od_repo_path=od_repo_path)
11+
updateOD(od_path=od_repo_path)

0 commit comments

Comments
 (0)