Skip to content

Commit

Permalink
use new project version
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieVangeysel committed Aug 22, 2024
1 parent 0f75626 commit df36511
Show file tree
Hide file tree
Showing 9 changed files with 2,320 additions and 544 deletions.
4 changes: 3 additions & 1 deletion api/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ readme.md
#deps def
package-lock.json

.tap/
.dockerignore
Dockerfile
Dockerfile
config.js
2 changes: 1 addition & 1 deletion api/.npmrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
global-style=true
install-strategy=shallow
engine-strict=true
legacy-peer-deps=true
lockfile-version=3
Expand Down
41 changes: 18 additions & 23 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,46 @@
# ---- Build ----
FROM groupclaes/npm AS build
FROM --platform=linux/amd64 groupclaes/npm AS build

# change the working directory to new exclusive app folder
WORKDIR /usr/src/app

# copy package file
COPY package.json ./
# copy project file
COPY ./ ./

# install node packages
RUN npm i

USER root
RUN npm install esbuild --global
RUN npm install

# copy project
COPY src/ ./

# build project
# create esbuild package
RUN esbuild ./index.ts --bundle --platform=node --minify --packages=external --external:'./config' --outfile=index.min.js

# ---- Build ----
FROM groupclaes/npm AS deps

# ---- Deps ----
FROM --platform=linux/amd64 groupclaes/npm AS depedencies

# change the working directory to new exclusive app folder
WORKDIR /usr/src/app

# set current user to node
USER node

# copy package file
COPY package.json ./

# install node packages
RUN npm i
RUN npm install

# from base image node
FROM groupclaes/node AS release

# --- release ---
FROM --platform=linux/amd64 groupclaes/node AS release

# set current user to node
USER node

# change the working directory to new exclusive app folder
WORKDIR /usr/src/app

# copy file and packages from build
COPY --from=build /usr/src/app/index.min.js ./index.js
COPY --from=deps /usr/src/app/node_modules/ ./node_modules
# copy dependencies
COPY --chown=node:node --from=depedencies /usr/src/app ./

# copy project file
COPY --chown=node:node --from=build /usr/src/app/index.min.js ./

# command to run when intantiate an image
CMD ["node","index.js"]
CMD ["node","index.min.js"]
21 changes: 0 additions & 21 deletions api/build.sh

This file was deleted.

15 changes: 15 additions & 0 deletions api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import server from './src'
const cfg = require('./config')

const main = async function () {
const fastify = await server(cfg);

['SIGTERM', 'SIGINT'].forEach(signal => {
process.on(signal, async () => {
await fastify?.close()
process.exit(0)
})
})
}

main()
Loading

0 comments on commit df36511

Please sign in to comment.