Skip to content
Open
Show file tree
Hide file tree
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
35 changes: 35 additions & 0 deletions 05-example-web-application/api-golang/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM golang:1.19-buster as build

WORKDIR /app

RUN useradd -u 1001 madu

COPY go.mod go.sum ./

RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go mod download

COPY . .

RUN go build \
-ldflags="-linkmode external -extldflags -static" \
-tags netgo \
-o api-golang

###
FROM scratch

COPY --from=build /app/api-golang api-golang

COPY --from=build /etc/passwd /etc/paaswd

COPY --from=build /app/api-golang api-golang

USER madu

ENV GIN-MODE release

EXPOSE 8080

CMD [ "/api-golang" ]
19 changes: 19 additions & 0 deletions 05-example-web-application/api-node/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:19.6-alpine

WORKDIR /usr/src/app

ENV NODE_ENV production

COPY package.json ./

RUN --mount=type=cache,target=/usr/src/app/.npm \
npm set cache /usr/src/app/.npm && \
npm ci --only=production

USER node

COPY --chown=node:node ./src .

EXPOSE 3000

CMD ["node", "index.js"]
22 changes: 22 additions & 0 deletions 05-example-web-application/client-react/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM node:19.4-bullseye as build

WORKDIR /usr/src/app

COPY package*.json ./

RUN --mount=type=cache,target=/usr/src/app/.npm \
npm set cache /usr/src/app/.npm && \
npm ci

COPY . .

RUN npm run build

###
FROM nginxinc/nginx-unprivileged:1.23-alpine-perl

COPY nginx.conf /etc/nginx/conf.d/default.conf

COPY --from=build /usr/src/app/dist/ /usr/share/nginx/html

EXPOSE 8080