Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use golang:alpine for golang docker image #194

Merged
merged 2 commits into from
Jan 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions configureWorkspace/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,28 @@ CMD ${cmd}`;
case 'go':

return `
# golang:onbuild automatically copies the package source,
# fetches the application dependencies, builds the program,
# and configures it to run on startup
FROM golang:onbuild
LABEL Name=${serviceName} Version=${version}
#build stage
FROM golang:alpine AS builder
WORKDIR /go/src/app
COPY . .
RUN apk add --no-cache git
RUN go-wrapper download # "go get -d -v ./..."
RUN go-wrapper install # "go install -v ./..."

#final stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder /go/bin/app /app
ENTRYPOINT ./app
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be /app?

LABEL Name=${serviceName} Version=${version}
EXPOSE ${port}

# For more control, you can copy and build manually
# FROM golang:latest
# LABEL Name=${serviceName} Version=${version}
# RUN mkdir /app
# ADD . /app/
# WORKDIR /app
# RUN go build -o main .
# EXPOSE ${port}
# CMD ["/app/main"]
`;

case '.net core':

return `
FROM microsoft/aspnetcore:1
LABEL Name=${serviceName} Version=${version}
LABEL Name=${serviceName} Version=${version}
ARG source=.
WORKDIR /app
EXPOSE ${port}
Expand All @@ -54,7 +53,7 @@ ENTRYPOINT dotnet ${serviceName}.dll

return `
FROM docker/whalesay:latest
LABEL Name=${serviceName} Version=${version}
LABEL Name=${serviceName} Version=${version}
RUN apt-get -y update && apt-get install -y fortunes
CMD /usr/games/fortune -a | cowsay
`;
Expand Down Expand Up @@ -113,7 +112,7 @@ function genDockerComposeDebug(serviceName: string, platform: string, port: stri

const cmdArray: string[] = cmd.split(' ');
if (cmdArray[0].toLowerCase() === 'node') {
cmdArray.splice(1, 0, '--inspect=0.0.0.0:9229');
cmdArray.splice(1, 0, '--inspect=0.0.0.0:9229');
cmd = `command: ${cmdArray.join(' ')}`;
} else {
cmd = '## set your startup file here\n command: node --inspect index.js';
Expand Down Expand Up @@ -286,7 +285,7 @@ export async function configure(): Promise<void> {

const serviceName = path.basename(folder.uri.fsPath).toLowerCase();
const pkg = await readPackageJson(folder);

await Promise.all(Object.keys(DOCKER_FILE_TYPES).map((fileName) => {
return createWorkspaceFileIfNotExists(fileName, DOCKER_FILE_TYPES[fileName]);
}));
Expand Down