Gitlab CI - Docker中的Docker - 如何维护管道?

时间:2018-01-29 08:02:13

标签: docker asp.net-core dockerfile gitlab-ci

我正在尝试在docker构建中使用gitlab CI作为docker,我已经启动并运行了。 我的问题是gitlab的漂亮管道功能有点丢失,因为整个构建,测试等......阶段是在DockerFile而不是yaml中定义的。 我现在只在yaml中有一个阶段。

有没有办法在docker中使用docker并仍然利用gitlab管道?

相关文件。
Dockerfile

# Stage 1 - require and update image
FROM microsoft/aspnetcore-build:2.0.0 AS build
# Update the imgage OS 
RUN apt-get update \
    && apt-get install -y
# set the container working directory
WORKDIR /code

# Stage 2 - copy data
# caches restore result by copying csproj file separately
COPY src/Nuget.Config ./src/

COPY src/Inflow.NewsMl.FileLoader/Inflow.NewsMl.FileLoader.csproj ./src/Inflow.NewsMl.FileLoader/ 
RUN dotnet restore src/Inflow.NewsMl.FileLoader/Inflow.NewsMl.FileLoader.csproj --configfile /code/src/Nuget.Config

COPY src/Inflow.NewsMl.FileLoader.Test/Inflow.NewsMl.FileLoader.Test.csproj ./src/Inflow.NewsMl.FileLoader.Test/ 
RUN dotnet restore src/Inflow.NewsMl.FileLoader.Test/Inflow.NewsMl.FileLoader.Test.csproj --configfile /code/src/Nuget.Config

# Copy the rest
COPY . .

# Stage 3 - Build and test
RUN dotnet test src/Inflow.NewsMl.FileLoader.Test/Inflow.NewsMl.FileLoader.Test.csproj

# Stage 4 - Deploym to image
RUN dotnet publish src/Inflow.NewsMl.FileLoader --output /code/output --configuration Release

FROM microsoft/aspnetcore:2.0.0

COPY --from=build /code/output /app

WORKDIR /app

ENTRYPOINT [ "dotnet", "Inflow.NewsMl.FileLoader.dll" ]

和ci runner yaml

image: docker:latest

.before_script:
  - docker info

variables:
  DOCKER_DRIVER: overlay
  CONTAINER_TEST_IMAGE: infomedia/newsml.fileloader:CI_COMMIT_SHA
  #$CI_COMMIT_TAG

services:
- docker:dind

stages:
- build

build:
  stage: build
  #only:
  #  - tags
  #except:
  #  - master
  script:
  - docker build -t $CONTAINER_TEST_IMAGE .

0 个答案:

没有答案