用于桌面应用程序的Docker构建

时间:2018-07-12 12:25:36

标签: docker gitlab dockerfile desktop-application gitlab-ci

我有一个使用(C ++ / QT IFW)开发的桌面GUI应用程序。该应用程序的存储库位于gitlab中。使用gitlab-ci.yml文件配置Gitlab CI / CD。安装在Windows Server 2012上的gitlab运行程序将构建桌面应用程序。内部版本(.exe应用程序)的输出被压缩为zip格式,并交付给工件服务器。最终用户下载工件(.ZIP文件),然后在其Windows 7/10系统上安装该应用程序。假设我想在新的Windows Server 2016上构建,我必须安装所有构建工具以及gitlab运行程序。在这种情况下如何使用docker?我想使用docker来创建或复制构建环境。

* Can I create a docker image for build tools?
* build the source code inside the docker container
*  upload to the artifactory server the output of build (.exe application) in compressed zip format.
* Deliver the compressed ZIP file for the end user via artifactory server
* The end user downloads the ZIP file from artifactory server and installs the tool on their local machine

gitlab-ci.yml

variables:
  PROJECT_NAME: "Demo Project"
  GIT_SSL_NO_VERIFY: "true"
  REPOSITORY_NAME: "test" 
  ARTIFACTORY_ROOT_PATH: ""
  ARTIFACTORY_WEBSITE: ""
  ARTIFACTORY_USER: ""
  CURL: "C:\\build-tools\\curl\\bin\\curl.exe"
  JQ: "C:\\build-tools\\jq\\jq-win64.exe"
  TEMPFILE: "C:\\build-tools\\jq\\temp.txt" 
  REPLACE_VERSION_RELEASE_DATE: "C:\\build-tools\\ReplaceVersionReleasedate\\ReplaceVersionReleasedate.exe"
  ZIP: "C:\\Program Files\\7-Zip\\7z.exe"
  QTIFW_REPOGEN: "c:\\QT\\QtIFW-3.0.4\\bin\\repogen"
  JFROG_CLI: "C:\\build-tools\\JFROG-CLI\\jfrog"
  JOM: "C:\\Qt\\Tools\\QtCreator\\bin\\jom.exe"
before_script:
  - echo "starting build for %PROJECT_NAME%"
  - SET BUILDVER=%CI_COMMIT_TAG:~3%
  - set PATH=C:\Qt\5.10.1\msvc2015_64\bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC;%PATH%
  - call vcvarsall.bat x86_amd64
stages:
  - build
  - deploy_rv
build:
  stage: build
  script:
  - echo "Building (Release)..."
  - 'RMDIR /S /Q dist'
  - 'qmake test.pro -spec win32-msvc "CONFIG+=release" "CONFIG+=qml_release"'
  - '%JOM% qmake_all'
  - '%JOM%'
  - '%JOM% install'
  - 'qmake test.pro -spec win32-msvc "CONFIG+=release" "CONFIG+=qml_release"'
  - '%JOM% qmake_all'<
  - '%JOM%'
  - '%JOM% install'
  - 'MD dist\release_build\test_app'
  - echo "Copying files into build folder ..."
  - 'xcopy test_app\mlapp_redist\*.* dist\release_build\test_app /E /Y >NUL'

  artifacts:
    paths:
    - dist/

deploy_rv:
  stage: deploy_rv
  script:
  - echo "Deploy Artifact..."
  # Compress Artifact
  - '"%ZIP%" a test.rv.zip dist/'
  - '"%ZIP%" a test.rv-%BUILDVER%.zip dist/'

  # Configure JFrog CLI with parameters of your Artifactory instance
  - '%JFROG_CLI% rt config --url  %ARTIFACTORY_WEBSITE% --user %ARTIFACTORY_USER% --apikey %API_KEY%'

  - 'set mydate=%DATE:~6,4%-%DATE:~3,2%-%DATE:~0,2%'

  - '%JFROG_CLI% rt u "test.rv.zip" %ARTIFACTORY_ROOT_PATH%/tools/test/test.rv.zip --build-name=test.rv --build-number=%BUILDVER%  --props releasenote=%releasenote%;releaseversion=%BUILDVER%;releasedate=%mydate% --flat=false'
  - '%JFROG_CLI% rt u "test.rv-%BUILDVER%.zip" %ARTIFACTORY_ROOT_PATH%/tools/test/test.rv-%BUILDVER%.zip --build-name=test.rv-%BUILDVER% --build-number=%BUILDVER%  --props releasenote=%releasenote%;releaseversion=%BUILDVER%;releasedate=%mydate% --flat=false'

  #  Publish build info to Artifactory.
  - '%JFROG_CLI% rt bp test.rv %BUILDVER%'
  - '%JFROG_CLI% rt bp test.rv-%BUILDVER% %BUILDVER%'

  # Trigger to update other Repository
  - '%CURL% -X POST -F token=%My_TOKEN% -F ref=master -F "variables[RELEASE]=true" -F "variables[PROGRAM]=test" --insecure https://gitlab/project/trigger/pipeline'
  only:
  - /^(rv-)(\d+\.)(\d+\.)(\d+)$/

dockerfile

# Use the latest Windows Server Core image.
FROM microsoft/windowsservercore

ENV chocolateyUseWindowsCompression false

RUN powershell -Command \
    iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')); \
    choco feature disable --name showDownloadProgress

RUN choco install visualstudio2015professional
RUN choco install qtcreator
RUN choco install curl
RUN choco install jq
RUN choco install 7zip.install
RUN choco install jfrog-cli
RUN choco install jom

0 个答案:

没有答案