Skip to content

Commit

Permalink
feat: service dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
njfamirm committed Nov 26, 2023
1 parent 37b8e3a commit f1cd7df
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
46 changes: 46 additions & 0 deletions cloud/service.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
FROM docker.io/library/node:20-alpine as builder

WORKDIR /app

COPY . .
RUN if [ -f *.lock ]; then \
yarn install --immutable; \
else \
yarn install; \
fi;

ENV NODE_ENV production

RUN yarn build:ts

# Build target package
ARG packageSource
RUN set -ex;\
if [ -z "$packageSource" ]; then\
echo 'packageSource not defined'>&2;\
exit 1;\
fi;
RUN set -ex;\
cd "$packageSource"; pwd; ls -lahF;\
yarn build;

# ---

FROM docker.io/library/node:20-alpine as service

WORKDIR /app

CMD ["yarn", "serve"]

ENV NODE_ENV production
ENV NODE_OPTIONS --enable-source-maps
ENV HOST 0.0.0.0
ENV PORT 80
EXPOSE 80

# Copy builded files from last stage
ARG packageSource
COPY ${packageSource}/package.json ./
COPY ${packageSource}/dist ./dist

# RUN pwd; ls -lAhF;
7 changes: 4 additions & 3 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,21 @@
"b": "yarn run build",
"c": "yarn run clean",
"cb": "run-s clean build",
"cw": "run-s clean watch",
"s": "yarn run start",
"w": "yarn run watch",
"l": "run-s 'lint:*'",
"l": "yarn lint",
"lint": "run-s 'lint:*'",
"lint:ts": "tsc --build",
"start": "NODE_OPTIONS=--enable-source-maps run-s clean build serve",
"build": "yarn run build:es",
"build:es": "yarn node ./build.js",
"clean": "rm -rf dist build .tsbuildinfo",
"clean": "rm -rf dist .tsbuildinfo",
"serve": "yarn node --enable-source-maps dist/index.js",
"serve:debug": "yarn node --inspect --enable-source-maps dist/index.js",
"watch": "run-s clean build && run-p watch:es watch:node",
"watch:node": "nodemon -w dist/ --enable-source-maps dist/index.js",
"watch:debug-node": "nodemon -w dist/ --inspect --enable-source-maps dist/index.js",
"watch:ts": "yarn run build:ts --watch --preserveWatchOutput",
"watch:es": "yarn run build:es --watch"
},
"devDependencies": {
Expand Down

0 comments on commit f1cd7df

Please sign in to comment.