-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rewrite to use only nginx (#222)
- Loading branch information
1 parent
387008e
commit 1bc77aa
Showing
30 changed files
with
1,056 additions
and
2,278 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ coverage | |
cache | ||
.husky | ||
pnpm-lock.yaml | ||
*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,17 @@ | ||
ARG NODE_VERSION=18 | ||
ARG PNPM_VERSION=8 | ||
ARG TINI_VERSION="v0.19.0" | ||
ARG COMMIT_SHA="unknown" | ||
|
||
################################################################ | ||
# # | ||
# Prepare alpine image # | ||
# # | ||
################################################################ | ||
|
||
FROM node:${NODE_VERSION}-alpine as node-alpine | ||
|
||
ARG PNPM_VERSION | ||
ARG TINI_VERSION | ||
|
||
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini | ||
|
||
RUN chmod +x /tini | ||
RUN apk --no-cache add curl | ||
RUN curl -sf https://gobinaries.com/tj/node-prune | sh | ||
RUN npm install --global pnpm@${PNPM_VERSION} | ||
|
||
################################################################ | ||
# # | ||
# Prepare distroless image # | ||
# # | ||
################################################################ | ||
|
||
FROM gcr.io/distroless/nodejs${NODE_VERSION}-debian11:nonroot as node-distroless | ||
|
||
################################################################ | ||
# # | ||
# Install all dependencies and build TypeScript # | ||
# # | ||
################################################################ | ||
|
||
FROM node-alpine as build-js | ||
|
||
COPY package.json package.json | ||
COPY pnpm-lock.yaml pnpm-lock.yaml | ||
|
||
RUN pnpm fetch | ||
|
||
COPY tsconfig.base.json tsconfig.base.json | ||
COPY tsconfig.prod.json tsconfig.prod.json | ||
COPY src src | ||
FROM nginx:1-alpine | ||
|
||
RUN pnpm install --offline --frozen-lockfile | ||
RUN ./node_modules/.bin/tsc --project ./tsconfig.prod.json | ||
|
||
################################################################ | ||
# # | ||
# Install only production dependencies & prune unused files # | ||
# # | ||
################################################################ | ||
|
||
FROM node-alpine as install-prod-deps | ||
|
||
ENV NODE_ENV="production" | ||
|
||
COPY --from=build-js package.json package.json | ||
COPY --from=build-js pnpm-lock.yaml pnpm-lock.yaml | ||
|
||
RUN pnpm fetch | ||
RUN pnpm install --offline --frozen-lockfile --prod | ||
RUN node-prune | ||
|
||
################################################################ | ||
# # | ||
# Copy only necessary data for runtime # | ||
# # | ||
################################################################ | ||
|
||
FROM node-distroless as final | ||
ARG COMMIT_SHA="unknown" | ||
|
||
ARG COMMIT_SHA | ||
COPY ./nginx/templates /etc/nginx/templates | ||
|
||
ENV NODE_OPTIONS="--enable-source-maps --dns-result-order=ipv4first" | ||
ENV NODE_ENV="production" | ||
ENV COMMIT_SHA=${COMMIT_SHA} | ||
|
||
COPY --from=node-alpine --chown=nonroot:nonroot /tini /tini | ||
COPY --from=build-js --chown=nonroot:nonroot package.json package.json | ||
COPY --from=build-js --chown=nonroot:nonroot build build | ||
COPY --from=install-prod-deps --chown=nonroot:nonroot node_modules node_modules | ||
|
||
USER nonroot:nonroot | ||
|
||
ENTRYPOINT ["/tini", "--"] | ||
|
||
CMD ["/nodejs/bin/node", "./build/src/main.js"] | ||
ENV PROXY_PORT=8000 | ||
ENV CLIENT_MAX_BODY_SIZE=20m | ||
ENV ERROR_LOG_LEVEL=error | ||
ENV WEB_SDK_HOST=web-sdk.smartlook.com | ||
ENV MANAGER_HOST=manager.eu.smartlook.cloud | ||
ENV ASSETS_PROXY_HOST=assets-proxy.smartlook.cloud | ||
ENV WEB_SDK_WRITER_HOST=web-writer.eu.smartlook.cloud | ||
ENV MOBILE_SDK_WRITER_HOST=sdk-writer.eu.smartlook.cloud | ||
|
||
EXPOSE ${PROXY_PORT} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
version: '3' | ||
|
||
services: | ||
nginx: | ||
image: nginx:1-alpine | ||
container_name: nginx | ||
restart: unless-stopped | ||
ports: | ||
- 80:8000 | ||
environment: | ||
COMMIT_SHA: dev | ||
PROXY_PORT: 8000 | ||
CLIENT_MAX_BODY_SIZE: 20m | ||
ERROR_LOG_LEVEL: error | ||
WEB_SDK_HOST: web-sdk.smartlook.com | ||
MANAGER_HOST: manager.eu.smartlook.cloud | ||
ASSETS_PROXY_HOST: assets-proxy.smartlook.cloud | ||
WEB_SDK_WRITER_HOST: web-writer.eu.smartlook.cloud | ||
MOBILE_SDK_WRITER_HOST: sdk-writer.eu.smartlook.cloud | ||
volumes: | ||
- ./nginx/templates:/etc/nginx/templates | ||
- nginx_data:/etc/nginx | ||
|
||
volumes: | ||
nginx_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.