Skip to content

Commit

Permalink
attempt NuGet binary caching via GitHub Packages in docker image build
Browse files Browse the repository at this point in the history
  • Loading branch information
nam20485 committed Oct 20, 2023
1 parent 1d091a0 commit efb5dc1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ env:
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
#VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite'


jobs:
Expand Down Expand Up @@ -85,7 +86,10 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
file: Dockerfile_OdbDesignServer

build-args:
OWNER=nam20485
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
VCPKG_BINARY_SOURCES="clear;nuget,GitHub,readwrite"

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
Expand Down
35 changes: 30 additions & 5 deletions Dockerfile_OdbDesignServer
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
FROM debian:bookworm-20231009 AS build

ARG OWNER=nam20485
ARG GITHUB_TOKEN="PASSWORD"
ARG VCPKG_BINARY_SOURCES=""

# install dependencies
RUN apt-get update && \
apt-get install -y -q --no-install-recommends \
Expand All @@ -12,28 +16,49 @@ RUN apt-get update && \
g++ \
ninja-build \
# python3-dev \
#build-essential \
build-essential \
git \
zip \
unzip \
tar \
pkg-config \
mono-complete \
&& \
rm -rf /var/lib/apt/lists/*

ENV VCPKG_ROOT=/root/src/github/microsoft/vcpkg

# install vcpkg
WORKDIR /root/src/github/microsoft
ENV VCPKG_ROOT=/root/src/github/microsoft/vcpkg
#WORKDIR /root/src/github/microsoft
RUN git clone https://github.com/Microsoft/vcpkg.git ${VCPKG_ROOT}
WORKDIR ${VCPKG_ROOT}
RUN ./bootstrap-vcpkg.sh

# set vcpkg to use NuGet for binary caching
ENV VCPKG_BINARY_SOURCES=${VCPKG_BINARY_SOURCES}

#RUN ./vcpkg --help
#RUN ./vcpkg fetch nuget

# setup NuGet to use GitHub Packages as a source so vcpkg binary cache can use it
RUN mono `./vcpkg fetch nuget | tail -n 1` \
sources add \
-source "https://nuget.pkg.github.com/${OWNER}/index.json" \
-storepasswordincleartext \
-name "GitHub" \
-username ${OWNER} \
-password "${GITHUB_TOKEN}"

RUN mono `./vcpkg fetch nuget | tail -n 1` \
setapikey "${GITHUB_TOKEN}" \
-source "https://nuget.pkg.github.com/${OWNER}/index.json"

# pre-install vcpgk packages BEFORE cmake configure
RUN mkdir -p /src/OdbDesign
WORKDIR /src/OdbDesign
COPY ./vcpkg.json .
RUN ${VCPKG_ROOT}/vcpkg install
RUN ${VCPKG_ROOT}/vcpkg install --debug
# RUN --mount=type=cache,target=/root/.cache \
# ${VCPKG_ROOT}/vcpkg install

# copy source
COPY . .
Expand Down

0 comments on commit efb5dc1

Please sign in to comment.