Skip to content

Commit

Permalink
part 3 code
Browse files Browse the repository at this point in the history
  • Loading branch information
marcel-dempers committed Jun 30, 2019
1 parent f06b588 commit 0147ab7
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 30 deletions.
23 changes: 22 additions & 1 deletion c#/dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
FROM mcr.microsoft.com/dotnet/core/sdk:2.2
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch as dev

RUN mkdir /work/
WORKDIR /work/

COPY ./src/work.csproj /work/work.csproj
RUN dotnet restore

COPY ./src/ /work/
RUN mkdir /out/
RUN dotnet publish --no-restore --output /out/ --configuration Release


###########START NEW IMAGE###########################################

FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim as prod

RUN mkdir /app/
WORKDIR /app/
COPY --from=dev /out/ /app/
RUN chmod +x /app/
CMD dotnet work.dll
4 changes: 2 additions & 2 deletions c#/src/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:20571",
"sslPort": 44382
"applicationUrl": "http://localhost:63846",
"sslPort": 44303
}
},
"profiles": {
Expand Down
2 changes: 2 additions & 0 deletions c#/src/work.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<RuntimeIdentifiers>linux-x64</RuntimeIdentifiers>
</PropertyGroup>



<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App"/>
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
Expand Down
52 changes: 30 additions & 22 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,49 +1,57 @@
version: "3"
version: "3.4"
services:
csharp: #docker run -it -v ${PWD}:/work -w /work -p 5000:5000 aimvector/csharp:1.0.0 /bin/sh
container_name: csharp
image: aimvector/csharp:1.0.0
build: ./c#
working_dir: /work
entrypoint: /bin/sh
stdin_open: true
tty: true
build:
context: ./c#
target: prod
#working_dir: /work #comment out for build.target:prod
#entrypoint: /bin/sh #comment out for build.target:prod
#stdin_open: true #comment out for build.target:prod
#tty: true #comment out for build.target:prod
volumes:
- ./c#/src/:/work
- ./c#/src/:/work/
ports:
- 5000:5000
golang: #docker run -it -v ${PWD}:/work -w /work -p 5001:5000 aimvector/golang:1.0.0 /bin/sh
container_name: golang
image: aimvector/golang:1.0.0
build: ./golang
working_dir: /work
entrypoint: /bin/sh
stdin_open: true
tty: true
build:
context: ./golang
target: prod
#working_dir: /work #comment out for build.target:prod
#entrypoint: /bin/sh #comment out for build.target:prod
#stdin_open: true #comment out for build.target:prod
#tty: true #comment out for build.target:prod
volumes:
- ./golang/src/:/work
ports:
- 5001:5000
nodejs: #docker run -it -v ${PWD}:/work -w /work -p 5002:5000 aimvector/nodejs:1.0.0 /bin/sh
container_name: nodejs
image: aimvector/nodejs:1.0.0
build: ./nodejs
working_dir: /work
entrypoint: /bin/sh
stdin_open: true
tty: true
build:
context: ./nodejs
target: prod
#working_dir: /work #comment out for build.target:prod
#entrypoint: /bin/sh #comment out for build.target:prod
#stdin_open: true #comment out for build.target:prod
#tty: true #comment out for build.target:prod
volumes:
- ./nodejs/src/:/work
ports:
- 5002:5000
python: #docker run -it -v ${PWD}:/work -w /work -p 5003:5000 aimvector/python:1.0.0 /bin/sh
container_name: python
image: aimvector/python:1.0.0
build: ./python
working_dir: /work
entrypoint: /bin/sh
stdin_open: true
tty: true
build:
context: ./python
target: prod
#working_dir: /work #comment out for build.target:prod
#entrypoint: /bin/sh #comment out for build.target:prod
#stdin_open: true #comment out for build.target:prod
#tty: true #comment out for build.target:prod
volumes:
- ./python/src/:/work
ports:
Expand Down
13 changes: 11 additions & 2 deletions golang/dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
FROM golang:1.12.5-alpine3.9 as builder
FROM golang:1.12.5-alpine3.9 as dev

# installing git
RUN apk update && apk upgrade && \
apk add --no-cache git

RUN go get github.com/sirupsen/logrus
RUN go get github.com/buaazp/fasthttprouter
RUN go get github.com/valyala/fasthttp
RUN go get github.com/valyala/fasthttp

WORKDIR /work
COPY ./src /work/
RUN go build -o app
###########START NEW IMAGE###################

FROM alpine:3.9 as prod
COPY --from=dev /work/app /
CMD ./app
Binary file removed golang/src/work
Binary file not shown.
17 changes: 16 additions & 1 deletion nodejs/dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
FROM node:12.4.0-alpine
FROM node:12.4.0-alpine as dev

RUN mkdir /work/
WORKDIR /work/

COPY ./src/package.json /work/package.json
RUN npm install

COPY ./src/ /work/


###########START NEW IMAGE###################

FROM dev as prod

CMD node .
22 changes: 20 additions & 2 deletions python/dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
FROM python:3.7.3-alpine3.9
FROM python:3.7.3-alpine3.9 as dev

RUN pip install flask
RUN mkdir /work/
WORKDIR /work/

COPY ./src/requirements.txt /work/requirements.txt
RUN pip install -r requirements.txt

COPY ./src/ /work/

###########START NEW IMAGE###################

FROM python:3.7.3-alpine3.9 as prod

RUN mkdir /app/
WORKDIR /app/

COPY --from=dev /work/ /app/
RUN pip install -r requirements.txt
ENV FLASK_APP=server.py
CMD flask run -h 0.0.0 -p 5000
1 change: 1 addition & 0 deletions python/src/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Flask == 1.0.3

0 comments on commit 0147ab7

Please sign in to comment.