chore: add docker build
This commit is contained in:
parent
49cbb36d52
commit
deacf02a18
4 changed files with 59 additions and 25 deletions
20
.dockerignore
Normal file
20
.dockerignore
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Adonis default .gitignore ignores
|
||||||
|
node_modules
|
||||||
|
build
|
||||||
|
coverage
|
||||||
|
.vscode
|
||||||
|
.DS_STORE
|
||||||
|
.env
|
||||||
|
tmp
|
||||||
|
|
||||||
|
# Additional .gitignore ignores (any custom file you wish)
|
||||||
|
.idea
|
||||||
|
|
||||||
|
# Additional good to have ignores for dockerignore
|
||||||
|
Dockerfile*
|
||||||
|
docker-compose*
|
||||||
|
.dockerignore
|
||||||
|
*.md
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
data/
|
||||||
17
Dockerfile
17
Dockerfile
|
|
@ -1,25 +1,23 @@
|
||||||
ARG NODE_IMAGE=node:22-slim
|
ARG NODE_IMAGE=node:22-alpine
|
||||||
|
|
||||||
###### First Stage - Creating base ######
|
FROM $NODE_IMAGE AS base
|
||||||
FROM $NODE_IMAGE as base
|
RUN apk --no-cache add dumb-init
|
||||||
RUN mkdir -p /home/node/app && chown node:node /home/node/app
|
RUN mkdir -p /home/node/app && chown node:node /home/node/app
|
||||||
RUN npm install --global pnpm
|
RUN npm install -g pnpm
|
||||||
WORKDIR /home/node/app
|
WORKDIR /home/node/app
|
||||||
USER node
|
USER node
|
||||||
RUN mkdir tmp
|
RUN mkdir tmp
|
||||||
|
|
||||||
###### Second Stage - Installing dependencies ######
|
|
||||||
FROM base AS dependencies
|
FROM base AS dependencies
|
||||||
COPY --chown=node:node ./package*.json ./
|
COPY --chown=node:node ./package.json ./
|
||||||
|
COPY --chown=node:node ./pnpm-lock.yaml ./
|
||||||
RUN pnpm install
|
RUN pnpm install
|
||||||
COPY --chown=node:node . .
|
COPY --chown=node:node . .
|
||||||
|
|
||||||
###### Third Stage - Building Stage ######
|
|
||||||
FROM dependencies AS build
|
FROM dependencies AS build
|
||||||
RUN node ace build
|
RUN node ace build
|
||||||
|
|
||||||
###### Final Stage - Production ######
|
FROM base AS production
|
||||||
FROM base as production
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV PORT=3333
|
ENV PORT=3333
|
||||||
ENV HOST=0.0.0.0
|
ENV HOST=0.0.0.0
|
||||||
|
|
@ -28,3 +26,4 @@ COPY --chown=node:node ./pnpm-lock.yaml ./
|
||||||
RUN pnpm install --prod
|
RUN pnpm install --prod
|
||||||
COPY --chown=node:node --from=build /home/node/app/build .
|
COPY --chown=node:node --from=build /home/node/app/build .
|
||||||
EXPOSE 3333
|
EXPOSE 3333
|
||||||
|
CMD [ "dumb-init", "node", "bin/server.js" ]
|
||||||
|
|
|
||||||
2
build.sh
Executable file
2
build.sh
Executable file
|
|
@ -0,0 +1,2 @@
|
||||||
|
docker build -t git.lamy-charrier.fr/khollise/api:v1.0 .
|
||||||
|
# docker push git.lamy-charrier.fr/khollise/api:v1.0
|
||||||
|
|
@ -4,7 +4,7 @@ services:
|
||||||
container_name: khollise-redis
|
container_name: khollise-redis
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:6379:6379"
|
- '127.0.0.1:6379:6379'
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:15
|
image: postgres:15
|
||||||
|
|
@ -17,19 +17,32 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/var/lib/postgresql/data
|
- ./data:/var/lib/postgresql/data
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:5432:5432"
|
- '127.0.0.1:5432:5432'
|
||||||
|
|
||||||
pgadmin:
|
api:
|
||||||
image: dpage/pgadmin4
|
image: git.lamy-charrier.fr/khollise/api:v1.0
|
||||||
container_name: pgadmin4_container
|
container_name: khollise-api
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
depends_on:
|
||||||
- "8888:80"
|
- redis
|
||||||
environment:
|
- postgres
|
||||||
PGADMIN_DEFAULT_EMAIL: nathan@lamy-charrier.fr
|
# Link env file
|
||||||
PGADMIN_DEFAULT_PASSWORD: securepass
|
env_file:
|
||||||
volumes:
|
- ./prod.env
|
||||||
- pgadmin-data:/var/lib/pgadmin
|
ports:
|
||||||
|
- '3333:3333'
|
||||||
|
|
||||||
volumes:
|
# pgadmin:
|
||||||
pgadmin-data:
|
# image: dpage/pgadmin4
|
||||||
|
# container_name: pgadmin4_container
|
||||||
|
# restart: unless-stopped
|
||||||
|
# ports:
|
||||||
|
# - "8888:80"
|
||||||
|
# environment:
|
||||||
|
# PGADMIN_DEFAULT_EMAIL: nathan@lamy-charrier.fr
|
||||||
|
# PGADMIN_DEFAULT_PASSWORD: securepass
|
||||||
|
# volumes:
|
||||||
|
# - pgadmin-data:/var/lib/pgadmin
|
||||||
|
|
||||||
|
# volumes:
|
||||||
|
# pgadmin-data:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue