Skip to content

Commit

Permalink
feat: Change docker base image to Ubuntu-20.04 (microsoft#4516)
Browse files Browse the repository at this point in the history
* Ignoring .git folder for docker build

* changing base image to ubuntu

* adding verbose to health check on github actions

* fix varaible name

Co-authored-by: Dong Lei <donglei@microsoft.com>
  • Loading branch information
cdonke and boydc2014 committed Oct 26, 2020
1 parent b4f46c3 commit e95e278
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 52 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ Composer/packages/server/.composer
extensions/.build-cache.json
extensions/**/lib
extensions/**/dist

# ignore .git folders
**/.git
10 changes: 8 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ 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:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build
uses: docker/build-push-action@v2
with:
Expand All @@ -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)
65 changes: 15 additions & 50 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"]

0 comments on commit e95e278

Please sign in to comment.