Browse Source

Merge pull request #63 from rockstardev/feature/circleci

Multiarch Docker image for dcg
feature/auto_ssh
Nicolas Dorier 6 years ago
committed by GitHub
parent
commit
584c13268d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 71
      .circleci/config.yml
  2. 6
      docker-compose-generator/Dockerfile.linuxamd64
  3. 22
      docker-compose-generator/Dockerfile.linuxarm32v7
  4. 18
      docker-compose-generator/docker-compose-generator.sln

71
.circleci/config.yml

@ -0,0 +1,71 @@
version: 2
jobs:
# Define in CircleCi Project Variables: $DOCKERHUB_REPO, $DOCKERHUB_USER, $DOCKERHUB_PASS
# Publish jobs require those variables
publish_docker_linuxamd64:
machine:
docker_layer_caching: true
steps:
- checkout
- run:
command: |
cd docker-compose-generator
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
sudo docker build --pull -t $DOCKERHUB_REPO:latest-amd64 -f Dockerfile.linuxamd64 .
sudo docker push $DOCKERHUB_REPO:latest-amd64
publish_docker_linuxarm:
machine:
docker_layer_caching: true
steps:
- checkout
- run:
command: |
sudo docker run --rm --privileged multiarch/qemu-user-static:register --reset
#
cd docker-compose-generator
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
sudo docker build --pull -t $DOCKERHUB_REPO:latest-arm32v7 -f Dockerfile.linuxarm32v7 .
sudo docker push $DOCKERHUB_REPO:latest-arm32v7
publish_docker_multiarch:
machine:
enabled: true
image: circleci/classic:201808-01
steps:
- run:
command: |
# Turn on Experimental features
sudo mkdir $HOME/.docker
sudo sh -c 'echo "{ \"experimental\": \"enabled\" }" >> $HOME/.docker/config.json'
#
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
#
sudo docker manifest create --amend $DOCKERHUB_REPO:latest $DOCKERHUB_REPO:latest-amd64 $DOCKERHUB_REPO:latest-arm32v7
sudo docker manifest annotate $DOCKERHUB_REPO:latest $DOCKERHUB_REPO:latest-amd64 --os linux --arch amd64
sudo docker manifest annotate $DOCKERHUB_REPO:latest $DOCKERHUB_REPO:latest-arm32v7 --os linux --arch arm --variant v7
sudo docker manifest push $DOCKERHUB_REPO:latest -p
workflows:
version: 2
build_and_test:
jobs:
- test
publish:
jobs:
- publish_docker_linuxamd64:
filters:
branches:
only: dcg-latest
- publish_docker_linuxarm:
filters:
branches:
only: dcg-latest
- publish_docker_multiarch:
requires:
- publish_docker_linuxamd64
- publish_docker_linuxarm
filters:
branches:
only: dcg-latest

6
docker-compose-generator/Dockerfile → docker-compose-generator/Dockerfile.linuxamd64

@ -1,3 +1,4 @@
#
FROM microsoft/dotnet:2.1.500-sdk-alpine3.7 AS builder
WORKDIR /source
COPY src/docker-compose-generator.csproj docker-compose-generator.csproj
@ -6,10 +7,11 @@ RUN dotnet restore
COPY src/. .
RUN dotnet publish --output /app/ --configuration Release
#
FROM microsoft/dotnet:2.1.6-runtime-alpine3.7
WORKDIR /app
WORKDIR /datadir
RUN mkdir /datadir
WORKDIR /app
ENV APP_DATADIR=/datadir
VOLUME /datadir

22
docker-compose-generator/Dockerfile.linuxarm32v7

@ -0,0 +1,22 @@
# This is a manifest image, will pull the image with the same arch as the builder machine
FROM microsoft/dotnet:2.1.500-sdk AS builder
WORKDIR /source
COPY src/docker-compose-generator.csproj docker-compose-generator.csproj
# Cache some dependencies
RUN dotnet restore
COPY src/. .
RUN dotnet publish --output /app/ --configuration Release
# Force the builder machine to take make an arm runtime image. This is fine as long as the builder does not run any program
FROM microsoft/dotnet:2.1.6-aspnetcore-runtime-stretch-slim-arm32v7
WORKDIR /datadir
WORKDIR /app
ENV APP_DATADIR=/datadir
VOLUME /datadir
ENV INSIDE_CONTAINER=1
COPY --from=builder "/app" .
ENTRYPOINT ["dotnet", "docker-compose-generator.dll"]

18
docker-compose-generator/docker-compose-generator.sln

@ -3,7 +3,14 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "docker-compose-generator", "src/docker-compose-generator.csproj", "{0900AF35-48E8-46E2-85B3-BA3847EE0844}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "docker-compose-generator", "src\docker-compose-generator.csproj", "{0900AF35-48E8-46E2-85B3-BA3847EE0844}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{8C1C711D-DEF1-474C-A9F6-AAE142412528}"
ProjectSection(SolutionItems) = preProject
..\.circleci\config.yml = ..\.circleci\config.yml
Dockerfile.linuxamd64 = Dockerfile.linuxamd64
Dockerfile.linuxarm32v7 = Dockerfile.linuxarm32v7
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -14,9 +21,6 @@ Global
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0900AF35-48E8-46E2-85B3-BA3847EE0844}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0900AF35-48E8-46E2-85B3-BA3847EE0844}.Debug|Any CPU.Build.0 = Debug|Any CPU
@ -31,4 +35,10 @@ Global
{0900AF35-48E8-46E2-85B3-BA3847EE0844}.Release|x86.ActiveCfg = Release|Any CPU
{0900AF35-48E8-46E2-85B3-BA3847EE0844}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CADA76A8-7F2E-4132-900B-330F0D2D722B}
EndGlobalSection
EndGlobal

Loading…
Cancel
Save