Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dockerfile and docker-compose support #184

Merged
merged 16 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/node_modules
**/bin
**/obj
71 changes: 71 additions & 0 deletions .github/workflows/copilot-build-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: copilot-deploy-pipeline

on:
push:
branches:
- "main"
tags:
- "v*"
paths:
- "webapi/**"
- "webapp/**"
- ".github/workflows/copilot-build-images.yml"
pull_request:
branches:
- "main"
paths:
- "webapi/**"
- "webapp/**"
- ".github/workflows/copilot-build-images.yml"
huangyingting marked this conversation as resolved.
Show resolved Hide resolved

env:
REGISTRY: ghcr.io

jobs:
build-and-push-image:
name: Build and push images
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- dockerfile: ./docker/webapi/Dockerfile
image: ${{ github.repository }}-api
- dockerfile: ./docker/webapp/Dockerfile
image: ${{ github.repository }}-web
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Login container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ matrix.image }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}

- name: Build and push image
uses: docker/build-push-action@v3
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: VERSION=${{ github.ref_name }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -489,4 +489,4 @@ webapi/CopilotChatWebApi.sln
/deploy/

# Tesseract OCR language data files
*.traineddata
*.traineddata
33 changes: 33 additions & 0 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '3'
services:
chat-copilot-web:
image: chat-copilot-web
build:
context: ..
dockerfile: docker/webapp/Dockerfile
ports:
- 3000:3000
env_file:
- ../webapp/.env
depends_on:
chat-copilot-api:
condition: service_started
chat-copilot-api:
image: chat-copilot-api
build:
context: ..
dockerfile: docker/webapi/Dockerfile
ports:
- 8080:8080
glahaye marked this conversation as resolved.
Show resolved Hide resolved
env_file:
- ../webapi/.env
environment:
- MemoryStore__Qdrant__Host=http://qdrant
depends_on:
qdrant:
condition: service_started
qdrant:
image: qdrant/qdrant
ports:
- 6333:6333

26 changes: 26 additions & 0 deletions docker/webapi/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Learn about building .NET container images:
# https://github.com/dotnet/dotnet-docker/blob/main/samples/README.md
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /source

# generate dev-certs for https
RUN dotnet dev-certs https

# copy csproj and restore as distinct layers
COPY webapi/*.csproj .
RUN dotnet restore --use-current-runtime

# copy everything else and build app
COPY webapi/. .
RUN apt update && apt install -y wget
RUN wget -P data https://raw.githubusercontent.com/tesseract-ocr/tessdata/main/eng.traineddata
RUN dotnet publish --use-current-runtime --self-contained false --no-restore -o /app


# final stage/image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY --from=build /app .
COPY --from=build /root/.dotnet/corefx/cryptography/x509stores/my/* /root/.dotnet/corefx/cryptography/x509stores/my/

ENTRYPOINT ["./CopilotChatWebApi"]
17 changes: 17 additions & 0 deletions docker/webapp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# builder
FROM node:lts-alpine as builder
WORKDIR /app
COPY webapp/ .
RUN yarn install \
--prefer-offline \
--frozen-lockfile \
--non-interactive \
--production=false
huangyingting marked this conversation as resolved.
Show resolved Hide resolved

# final stage/image
FROM node:lts-alpine
WORKDIR /app
COPY --from=builder /app .
ENV HOST 0.0.0.0
EXPOSE 3000
ENTRYPOINT [ "yarn", "start" ]
Loading