From 9c2c9bd1a7ea993756c717e5eab51b0de900a342 Mon Sep 17 00:00:00 2001 From: Christiano Donke Date: Sun, 25 Oct 2020 11:26:04 -0300 Subject: [PATCH 1/4] Ignoring .git folder for docker build --- .dockerignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.dockerignore b/.dockerignore index a103066f4b..8fbda57fdb 100644 --- a/.dockerignore +++ b/.dockerignore @@ -20,3 +20,6 @@ Composer/packages/server/.composer extensions/.build-cache.json extensions/**/lib extensions/**/dist + +# ignore .git folders +**/.git \ No newline at end of file From 2142731d1be832d9100a76f07497d25f10684513 Mon Sep 17 00:00:00 2001 From: Christiano Donke Date: Sun, 25 Oct 2020 11:26:19 -0300 Subject: [PATCH 2/4] changing base image to ubuntu --- Dockerfile | 65 +++++++++++++----------------------------------------- 1 file changed, 15 insertions(+), 50 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6dc9d4c351..c7e394fcdf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,9 +6,14 @@ # before doing yarn install due to yarn workspace symlinking. # ################ - -FROM node:12-alpine as build - +FROM mcr.microsoft.com/dotnet/core/sdk:3.1-focal as base +RUN apt update \ + && apt -y install curl dirmngr apt-transport-https lsb-release ca-certificates \ + && curl -sL https://deb.nodesource.com/setup_12.x | bash - \ + && apt install -y nodejs \ + && npm install -g yarn + +FROM base as build ARG YARN_ARGS WORKDIR /src/Composer @@ -21,7 +26,7 @@ ENV NODE_ENV "production" ENV COMPOSER_BUILTIN_EXTENSIONS_DIR "/src/extensions" RUN yarn build:prod $YARN_ARGS -FROM node:12-alpine as composerbasic +FROM base as composerbasic ARG YARN_ARGS WORKDIR /app/Composer @@ -32,56 +37,16 @@ COPY --from=build /src/extensions ../extensions ENV NODE_ENV "production" RUN yarn --production --frozen-lockfile --force $YARN_ARGS && yarn cache clean -WORKDIR /app/Composer - -FROM composerbasic - -RUN apk add --no-cache \ - ca-certificates \ - \ - # .NET Core dependencies - krb5-libs \ - libgcc \ - libintl \ - libssl1.1 \ - libstdc++ \ - zlib -# Install .Net Core SDK -ENV \ - # Unset the value from the base image - ASPNETCORE_URLS= \ - # Disable the invariant mode (set in base image) - DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \ - # Enable correct mode for dotnet watch (only mode supported in a container) - DOTNET_USE_POLLING_FILE_WATCHER=true \ - LC_ALL=en_US.UTF-8 \ - LANG=en_US.UTF-8 \ - # Skip extraction of XML docs - generally not useful within an image/container - helps performance - NUGET_XMLDOC_MODE=skip \ - # PowerShell telemetry for docker image usage - POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-DotnetCoreSDK-Alpine-3.10 - -# Add dependencies for disabling invariant mode (set in base image) -RUN apk add --no-cache icu-libs - -# Install .NET Core SDK 3.1 -ENV DOTNET_SDK_VERSION 3.1.101 +FROM base +ENV NODE_ENV "production" -RUN wget -O dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-musl-x64.tar.gz \ - && dotnet_sha512='ce386da8bc07033957fd404909fc230e8ab9e29929675478b90f400a1838223379595a4459056c6c2251ab5c722f80858b9ca536db1a2f6d1670a97094d0fe55' \ - && echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \ - && mkdir -p /usr/share/dotnet \ - && tar -C /usr/share/dotnet -oxzf dotnet.tar.gz \ - && ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \ - && rm dotnet.tar.gz +WORKDIR /app/Composer +COPY --from=composerbasic /app .. -# Enable detection of running in a container -ENV DOTNET_RUNNING_IN_CONTAINER=true \ - # Set the invariant mode since icu_libs isn't included (see https://github.com/dotnet/announcements/issues/20) - DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true ENV COMPOSER_BUILTIN_EXTENSIONS_DIR "/app/extensions" ENV COMPOSER_REMOTE_EXTENSIONS_DIR "/app/remote-extensions" ENV COMPOSER_EXTENSION_DATA "/app/extensions.json" -CMD ["yarn","start:server"] + +CMD ["yarn","start:server"] \ No newline at end of file From 498fc5e8fd52bb92bff12d4f6f0d33d315c2c10a Mon Sep 17 00:00:00 2001 From: Christiano Donke Date: Sun, 25 Oct 2020 11:26:38 -0300 Subject: [PATCH 3/4] adding verbose to health check on github actions --- .github/workflows/docker.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 6f818ca078..f219b0db6b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -15,8 +15,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + - name: Cache Docker layers uses: actions/cache@v2 with: @@ -24,6 +26,7 @@ jobs: key: ${{ runner.os }}-buildx-${{ github.sha }} restore-keys: | ${{ runner.os }}-buildx- + - name: Build uses: docker/build-push-action@v2 with: @@ -34,12 +37,15 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache load: true + - name: Health check run: | - docker run -d --rm -p "5000:5000" botframework-composer + $containerId=$(docker run -d -p "5000:5000" botframework-composer) sleep 10 + docker logs $containerId curl -Is http://localhost:5000 | grep -q "200 OK" shell: bash + - name: Clean up if: always() - run: docker stop $(docker ps -a -q) + run: docker rm -f $(docker ps -a -q) From cb1599d50580615235c07b1fdbb6592dc289b8fc Mon Sep 17 00:00:00 2001 From: Christiano Donke Date: Sun, 25 Oct 2020 14:02:13 -0300 Subject: [PATCH 4/4] fix varaible name --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f219b0db6b..443f010199 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -40,7 +40,7 @@ jobs: - name: Health check run: | - $containerId=$(docker run -d -p "5000:5000" botframework-composer) + containerId=$(docker run -d -p "5000:5000" botframework-composer) sleep 10 docker logs $containerId curl -Is http://localhost:5000 | grep -q "200 OK"