Skip to content

Commit

Permalink
Build natives inside docker environment
Browse files Browse the repository at this point in the history
  • Loading branch information
gluschenko committed Jun 24, 2024
1 parent 4609df3 commit ad19a2f
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/LanguageIdentification.CLD3.ConsoleTest/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /repo
COPY ["src/LanguageIdentification.CLD3.ConsoleTest/LanguageIdentification.CLD3.ConsoleTest.csproj", "src/LanguageIdentification.CLD3.ConsoleTest/"]
COPY ["src/LanguageIdentification.CLD3/LanguageIdentification.CLD3.csproj", "src/LanguageIdentification.CLD3/"]
COPY ["src/LanguageIdentification.CLD3.Native/LanguageIdentification.CLD3.Native.csproj", "src/LanguageIdentification.CLD3.Native/"]
COPY ["src/LanguageIdentification.CLD3/LanguageIdentification.CLD3.csproj", "src/LanguageIdentification.CLD3/"]

### CLD3
COPY ["src/LanguageIdentification.CLD3.Native/Scripts/setup-build.sh", "src/LanguageIdentification.CLD3.Native/Scripts/"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<ContainerDevelopmentMode>Regular</ContainerDevelopmentMode>
<DockerfileContext>..\..</DockerfileContext>
<DockerfileRunArguments>--name language-identification-cld3</DockerfileRunArguments>
</PropertyGroup>

<ItemGroup>
Expand Down
8 changes: 8 additions & 0 deletions src/LanguageIdentification.CLD3.Native.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/LanguageIdentification.CLD3.Native/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
libcld3.so
17 changes: 17 additions & 0 deletions src/LanguageIdentification.CLD3.Native/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release

# RUN apt -y update
# RUN apt -y install protobuf-compiler libprotobuf-dev

WORKDIR /repo
COPY ["src/LanguageIdentification.CLD3.Native/LanguageIdentification.CLD3.Native.csproj", "src/LanguageIdentification.CLD3.Native/"]
COPY ["src/LanguageIdentification.CLD3.Native/Scripts/setup-build.sh", "src/LanguageIdentification.CLD3.Native/Scripts/"]
COPY ["src/LanguageIdentification.CLD3.Native/Scripts/run-build.sh", "src/LanguageIdentification.CLD3.Native/Scripts/"]
WORKDIR /repo/src/LanguageIdentification.CLD3.Native

RUN bash ./Scripts/setup-build.sh

COPY . .

ENTRYPOINT ["bash", "./Scripts/run-build.sh"]
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,43 @@
<DocumentationFile>..\LanguageIdentification.CLD3.Native.xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup>
<DockerImageName>cld3-builder</DockerImageName>
<DockerContainerName>cld3-builder</DockerContainerName>
<CurrentAbsolutePath>$(MSBuildThisFileDirectory)</CurrentAbsolutePath>
<ThirdPartyAbsolutePath>$([System.IO.Path]::Combine('$(MSBuildThisFileDirectory)', '../../third_party/cld3/'))</ThirdPartyAbsolutePath>
</PropertyGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent" Condition="'$(Configuration)'=='Release'">
<Exec Command="echo $(CurrentAbsolutePath)" />
<Exec Command="echo $(ThirdPartyAbsolutePath)" />
<Exec Command="echo 'docker build --file ./Dockerfile -t $(DockerImageName) ../..'" />
<Exec Command="echo 'docker run --name $(DockerContainerName) -v $(ThirdPartyAbsolutePath):/repo/third_party/cld3/ -v $(CurrentAbsolutePath):/repo/src/LanguageIdentification.CLD3.Native $(DockerImageName)'" />

<Exec Command="docker build --file ./Dockerfile -t $(DockerImageName) ../.." />
<Exec Command="docker run --name $(DockerContainerName) -v $(ThirdPartyAbsolutePath):/repo/third_party/cld3/ -v $(CurrentAbsolutePath):/repo/src/LanguageIdentification.CLD3.Native $(DockerImageName)" />
<Exec Command="docker rm $(DockerContainerName) --force" />
</Target>

<!--
<Target Name="PreBuild" BeforeTargets="PreBuildEvent" Condition="'$(Configuration)'=='Release' AND $([MSBuild]::IsOSPlatform('Linux'))">
<Exec Command="bash -c ./Scripts/setup-build.sh" />
<Exec Command="bash -c ./Scripts/run-build.sh" />
</Target>
-->

<ItemGroup>
<None Update="libcld3.so">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<None Include="..\.dockerignore" Link=".dockerignore">
<DependentUpon>$(DockerDefaultDockerfile)</DependentUpon>
</None>
</ItemGroup>

<ItemGroup>
<Content Include="libcld3.so">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<PackageCopyToOutput>true</PackageCopyToOutput>
<pack>true</pack>
</Content>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ python3 setup.py build_ext

ls -R build

cd ..
cd -
find "$workspace/build" -name "libcld3.so" -exec cp {} libcld3.so \;
rm -rf "$workspace"
ldd libcld3.so
Expand Down
8 changes: 8 additions & 0 deletions src/LanguageIdentification.CLD3.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ad19a2f

Please sign in to comment.