diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..62336a50f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,19 @@ +# User-specific files +*.suo +*.user +*.vs + +# Build results +build +bin +obj +publish + +# Test Output +_test-output + +# NodeJS +node_modules + +# Scripts (should be copied from node_modules on build) +**/wwwroot/scripts/**/*.* \ No newline at end of file diff --git a/.gitignore b/.gitignore index a1a6fe738..62336a50f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ build bin obj +publish # Test Output _test-output @@ -15,4 +16,4 @@ _test-output node_modules # Scripts (should be copied from node_modules on build) -**/wwwroot/scripts/**/*.* +**/wwwroot/scripts/**/*.* \ No newline at end of file diff --git a/tools/aspnetcore-build-phantomjs/Dockerfile b/Dockerfile.build similarity index 50% rename from tools/aspnetcore-build-phantomjs/Dockerfile rename to Dockerfile.build index e2ac1f7a9..71cac6778 100644 --- a/tools/aspnetcore-build-phantomjs/Dockerfile +++ b/Dockerfile.build @@ -1,5 +1,6 @@ -FROM microsoft/dotnet:1.1.0-sdk-msbuild-rc4 - +FROM microsoft/aspnetcore-build + + # Install runtime dependencies RUN apt-get update \ && apt-get install -y --no-install-recommends ca-certificates bzip2 libfontconfig \ @@ -24,4 +25,28 @@ RUN set -x \ RUN phantomjs --version -WORKDIR / \ No newline at end of file +COPY src/Squidex/package.json /tmp/package.json +RUN cd /tmp \ +&& npm install \ +&& npm rebuild node-sass + +COPY . . + +WORKDIR / + +# Build Frontend +RUN cp -a /tmp/node_modules /src/Squidex/ \ + && cd /src/Squidex \ + && npm run build:copy \ + && npm run build \ + && npm run test:coverage + +# Test Backend +RUN dotnet restore \ + && dotnet test tests/Squidex.Infrastructure.Tests/Squidex.Infrastructure.Tests.csproj \ + && dotnet test tests/Squidex.Core.Tests/Squidex.Core.Tests.csproj \ + && dotnet test tests/Squidex.Read.Tests/Squidex.Read.Tests.csproj \ + && dotnet test tests/Squidex.Write.Tests/Squidex.Write.Tests.csproj + +# Publish +RUN dotnet publish src/Squidex/Squidex.csproj --output /out/ --configuration Release \ No newline at end of file diff --git a/build.docker-compose.yml b/build.docker-compose.yml deleted file mode 100644 index f2dbce873..000000000 --- a/build.docker-compose.yml +++ /dev/null @@ -1,10 +0,0 @@ -version: '2' -services: - squidex-build: -# Use custom aspnet images where phantomjs is installed - build: tools/aspnetcore-build-phantomjs - volumes: - - .:/sln - working_dir: /sln -# Run the build script on local folder - entrypoint: ["sh", "./build.sh"] \ No newline at end of file diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 000000000..011c72ec0 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,11 @@ +# Build the image +docker build . -t build-image -f Dockerfile.build + +# Open the image +docker create --name build-cont build-image + +# Copy the output to the host file system +docker cp build-cont:/out ./publish + +# Cleanup +docker rm build-cont \ No newline at end of file diff --git a/build.sh b/build.sh deleted file mode 100644 index bd61f351d..000000000 --- a/build.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!bin/bash -set -e -cd src/Squidex -npm install -npm rebuild node-sass -npm rebuild phantomjs-prebuilt -npm run test:coverage -npm run build:copy -npm run build -cd ./../.. -dotnet restore -dotnet test tests/Squidex.Core.Tests/Squidex.Core.Tests.csproj -dotnet test tests/Squidex.Infrastructure.Tests/Squidex.Infrastructure.Tests.csproj -dotnet test tests/Squidex.Read.Tests/Squidex.Read.Tests.csproj -dotnet test tests/Squidex.Write.Tests/Squidex.Write.Tests.csproj -rm -rf $(pwd)/publish/web -dotnet publish src/Squidex/Squidex.csproj -c release -o $(pwd)/publish/web \ No newline at end of file diff --git a/src/Squidex/Squidex.csproj b/src/Squidex/Squidex.csproj index 2b1a06aec..83221855e 100644 --- a/src/Squidex/Squidex.csproj +++ b/src/Squidex/Squidex.csproj @@ -15,7 +15,6 @@ - PreserveNewest