-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use vcpkg.json only This is necessary to be able to build ParquetSharpNative offline with a populated vcpkg cache. * Ensure vcpkg builtin registry is up-to-date in CI runners If we reference a baseline that is too recent, some CI runner images will not have it. With this step we ensure it won't be the case. This used to be done via vcpkg-configuration.json, but we couldn't rely on it for offline devcontainer usage. * Improve Powershell build script Format via Powershell VS Code extension and fix linting issues. * Build native lib in both Debug and Release by default (unless in the CI) * Add devcontainer * Add devcontainer workflow * Update documentation about building ParquetSharp * Add solution to .gitignore
- Loading branch information
1 parent
05e4a7f
commit ea865a4
Showing
12 changed files
with
362 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
FROM mcr.microsoft.com/devcontainers/dotnet:0-7.0-bullseye-slim AS dotnet | ||
|
||
#==================================================================== | ||
|
||
FROM dotnet AS nuget | ||
|
||
USER vscode | ||
|
||
# Copy our projects | ||
COPY --chown=vscode:vscode . /tmp/build/ | ||
|
||
# Populate the nuget cache with all of our dependencies | ||
RUN for project in /tmp/build/csharp*; do \ | ||
dotnet restore $project; \ | ||
done | ||
|
||
#==================================================================== | ||
|
||
FROM dotnet AS cpp | ||
|
||
# Install the C++ dev tools | ||
RUN echo "deb http://deb.debian.org/debian bullseye-backports main" >> /etc/apt/sources.list \ | ||
&& apt-get update \ | ||
&& export DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get -y install --no-install-recommends \ | ||
bison \ | ||
build-essential \ | ||
cmake/bullseye-backports \ | ||
cppcheck \ | ||
flex \ | ||
gdb \ | ||
ninja-build \ | ||
pkg-config \ | ||
valgrind \ | ||
&& apt-get autoremove -y \ | ||
&& apt-get clean -y \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Set vcpkg environment variables | ||
ENV VCPKG_ROOT=/opt/vcpkg \ | ||
VCPKG_FORCE_SYSTEM_BINARIES=1 | ||
|
||
#==================================================================== | ||
|
||
FROM cpp AS vcpkg | ||
|
||
USER vscode | ||
|
||
# Install vcpkg | ||
RUN sudo mkdir -p $VCPKG_ROOT \ | ||
&& sudo chown vscode:vscode $VCPKG_ROOT \ | ||
&& git clone https://github.com/microsoft/vcpkg.git $VCPKG_ROOT \ | ||
&& cd $VCPKG_ROOT \ | ||
&& ./bootstrap-vcpkg.sh -disableMetrics | ||
|
||
# Copy our vcpkg manifest | ||
COPY --chown=vscode:vscode vcpkg.json /tmp/build/ | ||
|
||
# Populate the vcpkg binary cache with all of our dependencies | ||
RUN cd /tmp/build \ | ||
&& $VCPKG_ROOT/vcpkg install --clean-after-build \ | ||
&& bash -c 'rm -rf $VCPKG_ROOT/{buildtrees,downloads/temp,packages}' \ | ||
&& rm -rf * | ||
|
||
#==================================================================== | ||
|
||
FROM cpp AS devcontainer | ||
|
||
# Copy the nuget cache | ||
COPY --from=nuget --chown=vscode:vscode /home/vscode/.nuget/packages /home/vscode/.nuget/packages | ||
|
||
# Copy the installed vcpkg and its binary cache | ||
COPY --from=vcpkg --chown=vscode:vscode $VCPKG_ROOT $VCPKG_ROOT | ||
COPY --from=vcpkg --chown=vscode:vscode /home/vscode/.cache/vcpkg /home/vscode/.cache/vcpkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. | ||
{ | ||
"name": "ParquetSharp", | ||
|
||
// Use the prebuilt image. Comment this out if you want to make changes to it. | ||
"image": "ghcr.io/g-research/parquetsharp/devcontainer:latest", | ||
|
||
// Uncomment the following lines to build the container locally. You will also need | ||
// to comment out the "image" line above. | ||
// "build": { | ||
// "dockerfile": "./Dockerfile", | ||
// "context": ".." | ||
// }, | ||
|
||
// Necessary for C++ debugger to work. | ||
"capAdd": [ | ||
"SYS_PTRACE" | ||
], | ||
"securityOpt": [ | ||
"seccomp=unconfined" | ||
], | ||
|
||
// Configure tool-specific properties. | ||
"customizations": { | ||
// Configure properties specific to VS Code. | ||
"vscode": { | ||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
// Use vcpkg. | ||
"cmake.configureEnvironment": { | ||
"CMAKE_TOOLCHAIN_FILE": "/opt/vcpkg/scripts/buildsystems/vcpkg.cmake" | ||
}, | ||
|
||
// Run cmake configure on open. | ||
"cmake.configureOnOpen": true, | ||
|
||
// Remove some cmake elements from the status bar. | ||
"cmake.statusbar.advanced": { | ||
"buildTarget": { | ||
"visibility": "hidden" | ||
}, | ||
"kit": { | ||
"visibility": "hidden" | ||
}, | ||
"ctest": { | ||
"visibility": "hidden" | ||
} | ||
} | ||
}, | ||
|
||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"ms-dotnettools.csdevkit", | ||
"ms-dotnettools.csharp", | ||
"ms-vscode.cpptools", | ||
"ms-vscode.cmake-tools" | ||
] | ||
} | ||
}, | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "", | ||
|
||
// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
// "remoteUser": "vscode" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
** | ||
!vcpkg.json | ||
!*/*.csproj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
name: Build devcontainer image | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
paths: | ||
- ".devcontainer/**" | ||
- ".dockerignore" | ||
- "vcpkg.json" | ||
- "*/*.csproj" | ||
- ".github/workflows/devcontainer.yml" | ||
pull_request: | ||
branches: [master] | ||
paths: | ||
- ".devcontainer/**" | ||
- ".dockerignore" | ||
- "vcpkg.json" | ||
- "*/*.csproj" | ||
- ".github/workflows/devcontainer.yml" | ||
# Run once a week | ||
schedule: | ||
- cron: "34 2 * * 2" | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
jobs: | ||
build: | ||
name: Build devcontainer image | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
runner: [ubuntu-latest, ubuntu-20.04-arm64] | ||
runs-on: ${{ matrix.runner }} | ||
steps: | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Compute image info | ||
id: image | ||
run: | | ||
echo "name=ghcr.io/$(echo ${{ github.repository }} | tr A-Z a-z)/devcontainer" >> "$GITHUB_OUTPUT" | ||
echo "push=${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'schedule' }}" >> "$GITHUB_OUTPUT" | ||
- name: Compute image labels | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ steps.image.outputs.name }} | ||
tags: latest | ||
labels: | | ||
org.opencontainers.image.title=ParquetSharp devcontainer | ||
org.opencontainers.image.description=devcontainer for ParquetSharp | ||
- if: fromJson(steps.image.outputs.push) | ||
name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build image${{ fromJson(steps.image.outputs.push) && ' and push it by digest' || ''}} | ||
id: build | ||
uses: docker/build-push-action@v4 | ||
with: | ||
file: .devcontainer/Dockerfile | ||
labels: ${{ steps.meta.outputs.labels }} | ||
outputs: type=image,name=${{ steps.image.outputs.name }},push-by-digest=true,name-canonical=true,push=${{ steps.image.outputs.push }} | ||
cache-from: type=gha,scope=${{ github.ref }}-${{ matrix.runner }} | ||
cache-to: type=gha,scope=${{ github.ref }}-${{ matrix.runner }},mode=max | ||
- if: fromJson(steps.image.outputs.push) | ||
name: Export digest | ||
run: | | ||
mkdir -p /tmp/digests | ||
digest="${{ steps.build.outputs.digest }}" | ||
touch "/tmp/digests/${digest#sha256:}" | ||
- if: fromJson(steps.image.outputs.push) | ||
name: Upload digest | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: digests | ||
path: /tmp/digests/* | ||
if-no-files-found: error | ||
retention-days: 1 | ||
outputs: | ||
image_name: ${{ steps.image.outputs.name }} | ||
image_push: ${{ steps.image.outputs.push }} | ||
|
||
merge: | ||
name: Merge platforms | ||
if: fromJson(needs.build.outputs.image_push) | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
steps: | ||
- name: Download digests | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: digests | ||
path: /tmp/digests | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Create manifest list and push | ||
working-directory: /tmp/digests | ||
run: | | ||
docker buildx imagetools create -t ${{ needs.build.outputs.image_name }}:latest \ | ||
$(printf '${{ needs.build.outputs.image_name }}@sha256:%s ' *) | ||
- name: Inspect image | ||
run: docker buildx imagetools inspect ${{ needs.build.outputs.image_name }}:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.