Skip to content

Commit 3a3f69f

Browse files
committed
configure for dockerized
1 parent 2d455c9 commit 3a3f69f

File tree

5 files changed

+167
-2
lines changed

5 files changed

+167
-2
lines changed

.dockerignore

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,34 @@
1-
node_modules
1+
# Include any files or directories that you don't want to be copied to your
2+
# container here (e.g., local build artifacts, temporary files, etc.).
3+
#
4+
# For more help, visit the .dockerignore file reference guide at
5+
# https://docs.docker.com/engine/reference/builder/#dockerignore-file
6+
7+
**/.classpath
8+
**/.dockerignore
9+
**/.env
10+
**/.git
11+
**/.gitignore
12+
**/.project
13+
**/.settings
14+
**/.toolstarget
15+
**/.vs
16+
**/.vscode
17+
**/.next
18+
**/.cache
19+
**/*.*proj.user
20+
**/*.dbmdl
21+
**/*.jfm
22+
**/charts
23+
**/docker-compose*
24+
**/compose*
25+
**/Dockerfile*
26+
**/node_modules
27+
**/npm-debug.log
28+
**/obj
29+
**/secrets.dev.yaml
30+
**/values.dev.yaml
31+
**/build
32+
**/dist
33+
LICENSE
34+
README.md

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ GCS_PROJECT_ID=]app.io
2525
GCS_BUCKET_NAME=]app.appspot.com
2626

2727
GOOGLE_APPLICATION_CREDENTIALS=/app/dist/service-account.json
28+
29+
30+
# DOCKER ENV
31+
DB_EXPOSED_PORT=
32+
APP_EXPOSED_PORT=
33+
REDIS_EXPOSED_PORT=

Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# syntax=docker/dockerfile:1
2+
3+
# Comments are provided throughout this file to help you get started.
4+
# If you need more help, visit the Dockerfile reference guide at
5+
# https://docs.docker.com/engine/reference/builder/
6+
7+
ARG NODE_VERSION=18.18.0
8+
9+
FROM node:${NODE_VERSION}-alpine
10+
11+
# Use production node environment by default.
12+
ENV NODE_ENV production
13+
14+
15+
WORKDIR /app
16+
17+
# Download dependencies as a separate step to take advantage of Docker's caching.
18+
# Leverage a cache mount to /root/.yarn to speed up subsequent builds.
19+
# Leverage a bind mounts to package.json and yarn.lock to avoid having to copy them into
20+
# into this layer.
21+
RUN --mount=type=bind,source=package.json,target=package.json \
22+
--mount=type=bind,source=yarn.lock,target=yarn.lock \
23+
--mount=type=cache,target=/root/.yarn \
24+
yarn install --production --frozen-lockfile
25+
26+
# Run the application as a non-root user.
27+
USER node
28+
29+
# Copy the rest of the source files into the image.
30+
COPY . .
31+
32+
# Expose the port that the application listens on.
33+
EXPOSE 8100
34+
35+
# Run the application.
36+
CMD yarn run build
37+
CMD yarn run start:dev

compose.yaml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Comments are provided throughout this file to help you get started.
2+
# If you need more help, visit the Docker compose reference guide at
3+
# https://docs.docker.com/compose/compose-file/
4+
5+
# Here the instructions define your application as a service called "server".
6+
# This service is built from the Dockerfile in the current directory.
7+
# You can add other services your application may depend on here, such as a
8+
# database or a cache. For examples, see the Awesome Compose repository:
9+
# https://github.com/docker/awesome-compose
10+
name: "starter-kit"
11+
services:
12+
app:
13+
container_name: "starter-kit-app"
14+
build:
15+
context: .
16+
environment:
17+
NODE_ENV: production
18+
ports:
19+
- ${APP_EXPOSED_PORT:-8610}:3000
20+
depends_on:
21+
- pgsql
22+
volumes:
23+
- ./:/app
24+
networks:
25+
- starter-kit-network
26+
command:
27+
- /bin/sh
28+
- -c
29+
- |
30+
yarn run build
31+
yarn run start:dev
32+
33+
pgsql:
34+
container_name: "starter-kit-db"
35+
image: postgres:15
36+
environment:
37+
POSTGRES_PASSWORD: ${DB_PASS}
38+
POSTGRES_USER: ${DB_USER}
39+
POSTGRES_DB: ${DB_NAME}
40+
ports:
41+
- ${DB_EXPOSED_PORT:-8611}:5432
42+
networks:
43+
- starter-kit-network
44+
45+
redis:
46+
container_name: "starter-kit-redis"
47+
image: redis:7.0.5-alpine
48+
ports:
49+
- ${REDIS_EXPOSED_PORT:-8612}:6379
50+
51+
networks:
52+
- starter-kit-network
53+
54+
networks:
55+
starter-kit-network:
56+
driver: bridge
57+
# The commented out section below is an example of how to define a PostgreSQL
58+
# database that your application can use. `depends_on` tells Docker Compose to
59+
# start the database before your application. The `db-data` volume persists the
60+
# database data between container restarts. The `db-password` secret is used
61+
# to set the database password. You must create `db/password.txt` and add
62+
# a password of your choosing to it before running `docker-compose up`.
63+
# depends_on:
64+
# db:
65+
# condition: service_healthy
66+
# db:
67+
# image: postgres
68+
# restart: always
69+
# user: postgres
70+
# secrets:
71+
# - db-password
72+
# volumes:
73+
# - db-data:/var/lib/postgresql/data
74+
# environment:
75+
# - POSTGRES_DB=example
76+
# - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
77+
# expose:
78+
# - 5432
79+
# healthcheck:
80+
# test: [ "CMD", "pg_isready" ]
81+
# interval: 10s
82+
# timeout: 5s
83+
# retries: 5
84+
# volumes:
85+
# db-data:
86+
# secrets:
87+
# db-password:
88+
# file: db/password.txt
89+

nest-cli.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{
1414
"include": "i18n/**/*",
1515
"watchAssets": true,
16-
"outDir": "dist"
16+
"outDir": "dist/src"
1717
}
1818
]
1919
}

0 commit comments

Comments
 (0)