Skip to content

Commit

Permalink
Feature: docker image (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeguerin authored Nov 12, 2021
1 parent 88a51f1 commit 02d9f12
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 30 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
**/node_modules
**/dist

# Rush files
common/temp/**
package-deps.json

# tsc incremental build files
**/*.tsbuildinfo
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ using the preview.

## Getting Started

### Using Docker

[See docker documentation](./docs/docker.md)

### Using Node & Npm

1. Install [Node.js 14 LTS](https://nodejs.org/en/download/) and ensure you are able to run the `npm` command in a command prompt:

```
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "tmlanguage-generator",
"comment": "",
"type": "none"
}
],
"packageName": "tmlanguage-generator"
}
3 changes: 2 additions & 1 deletion common/config/rush/pnpm-lock.yaml

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

25 changes: 25 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# --------------------------------
# Build compiler
# --------------------------------
FROM node:16-alpine3.12 as builder

COPY . /app

WORKDIR /app
RUN npm install -g @microsoft/rush
RUN rush install
RUN rush rebuild

WORKDIR /app/packages/compiler
RUN npm pack

# --------------------------------
# Setup final image
# --------------------------------
FROM node:16-alpine3.12

COPY --from=builder /app/packages/compiler/*.tgz /tmp/compiler.tgz

RUN npm install -g /tmp/compiler.tgz && rm /tmp/compiler.tgz

ENTRYPOINT [ "cadl" ]
36 changes: 36 additions & 0 deletions docs/docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Use cadl via docker

Image: `azsdkengsys.azurecr.io/cadl`

Tags:

- Lastest from master: `alpine`, `latest`

## Usage

```bash
docker run \
-v "${pwd}:/wd" --workdir="/wd" \
-t azsdkengsys.azurecr.io/cadl \
# ... cadl args ...
```

**For usage in powershell replace `\` with `` ` ``**

### Install dependencies

```bash
docker run -v "${pwd}:/wd" --workdir="/wd" -t azsdkengsys.azurecr.io/cadl install
```

### Compile

```bash
docker run -v "${pwd}:/wd" --workdir="/wd" -t azsdkengsys.azurecr.io/cadl compile .
```

### Init a new project

```bash
docker run -v "${pwd}:/wd" --workdir="/wd" -t azsdkengsys.azurecr.io/cadl init
```
82 changes: 54 additions & 28 deletions eng/pipelines/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,57 @@ trigger:
- main
pr: none

pool:
vmImage: windows-2019

steps:
- task: NodeTool@0
inputs:
versionSpec: 14.x
displayName: Install Node.js

- script: echo '##vso[task.setvariable variable=CADL_VS_CI_BUILD;]true'
displayName: Enable official Visual Studio extension build

- script: node common/scripts/install-run-rush.js install
displayName: Install JavaScript Dependencies

- script: node packages/cadl-vs/scripts/build.js --restore
displayName: Restore .NET Dependencies

- script: node common/scripts/install-run-rush.js rebuild --verbose
displayName: Build

- script: node common/scripts/install-run-rush.js test-official
displayName: Test

- script: |
set NPM_AUTH_TOKEN=$(azure-sdk-npm-token)
node common/scripts/install-run-rush.js publish --publish --include-all --set-access-level public
displayName: Release
jobs:
- job: npm
displayName: Npm publish
pool:
vmImage: windows-2019
steps:
- task: NodeTool@0
inputs:
versionSpec: 14.x
displayName: Install Node.js

- script: echo '##vso[task.setvariable variable=CADL_VS_CI_BUILD;]true'
displayName: Enable official Visual Studio extension build

- script: node common/scripts/install-run-rush.js install
displayName: Install JavaScript Dependencies

- script: node packages/cadl-vs/scripts/build.js --restore
displayName: Restore .NET Dependencies

- script: node common/scripts/install-run-rush.js rebuild --verbose
displayName: Build

- script: node common/scripts/install-run-rush.js test-official
displayName: Test

- script: |
set NPM_AUTH_TOKEN=$(azure-sdk-npm-token)
node common/scripts/install-run-rush.js publish --publish --include-all --set-access-level public
displayName: Release
- job: docker
displayName: Docker build and publish
variables:
imageName: "azsdkengsys.azurecr.io/cadl"
pool:
vmImage: ubuntu-latest
steps:
- task: Docker@1
displayName: login
inputs:
azureSubscriptionEndpoint: "AzureSDKEngKeyVault Secrets"
azureContainerRegistry: azsdkengsys.azurecr.io
command: login

- script: |
docker build -f ./docker/Dockerfile \
-t $(imageName):latest \
-t $(imageName):alpine \
.
displayName: "Build"
- script: docker push $(imageName) --all-tags
displayName: "Push"
3 changes: 2 additions & 1 deletion packages/tmlanguage-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
},
"devDependencies": {
"@types/node": "~14.0.27",
"@types/plist": "~3.0.2"
"@types/plist": "~3.0.2",
"typescript": "~4.4.4"
}
}

0 comments on commit 02d9f12

Please sign in to comment.