diff --git a/05-example-web-application/api-golang/Dockerfile b/05-example-web-application/api-golang/Dockerfile new file mode 100644 index 00000000..d455a14a --- /dev/null +++ b/05-example-web-application/api-golang/Dockerfile @@ -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" ] \ No newline at end of file diff --git a/05-example-web-application/api-node/Dockerfile b/05-example-web-application/api-node/Dockerfile new file mode 100644 index 00000000..9acf75d4 --- /dev/null +++ b/05-example-web-application/api-node/Dockerfile @@ -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"] \ No newline at end of file diff --git a/05-example-web-application/client-react/Dockerfile b/05-example-web-application/client-react/Dockerfile new file mode 100644 index 00000000..d722ce5b --- /dev/null +++ b/05-example-web-application/client-react/Dockerfile @@ -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 \ No newline at end of file