Skip to content

Commit 1175711

Browse files
committed
feat(docker): added docker setup
1 parent 7c35ed8 commit 1175711

5 files changed

Lines changed: 366 additions & 21 deletions

File tree

Dockerfile

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
FROM node:20-bookworm AS dev
2+
3+
RUN apt-get update -y \
4+
&& apt-get install -y --no-install-recommends \
5+
git bash g++ make \
6+
&& rm -rf /var/lib/apt/lists/*
7+
8+
RUN corepack enable
9+
10+
WORKDIR /code
11+
RUN git config --global --add safe.directory /code
12+
13+
14+
COPY package.json pnpm-lock.yaml /code/
15+
RUN corepack prepare --activate
16+
# RUN npm install -g pnpm
17+
18+
# RUN pnpm install
19+
20+
21+
22+
# -------------------------- Nginx - Builder --------------------------------
23+
FROM dev AS nginx-build
24+
25+
COPY package.json pnpm-lock.yaml /code/
26+
27+
RUN corepack prepare --activate
28+
29+
RUN pnpm install
30+
31+
COPY . .
32+
33+
# # Build variables (Requires backend pulled)
34+
ENV APP_TITLE=APP_TITLE_PLACEHOLDER
35+
ENV APP_GRAPHQL_ENDPOINT=APP_GRAPHQL_ENDPOINT_PLACEHOLDER
36+
ENV APP_GRAPHQL_CODEGEN_ENDPOINT=./backend/schema.graphql
37+
38+
RUN pnpm generate:type && pnpm build
39+
# RUN pnpm build
40+
41+
# ---------------------------------------------------------------------------
42+
FROM nginx:1 AS nginx-serve
43+
44+
LABEL maintainer="Togglecorp Dev"
45+
LABEL org.opencontainers.image.source="https://github.com/ToogleCorp/nrcs-cms"
46+
47+
COPY ./nginx-serve/apply-config.sh /docker-entrypoint.d/
48+
COPY ./nginx-serve/nginx.conf.template /etc/nginx/templates/default.conf.template
49+
COPY --from=nginx-build /code/build /code/build
50+
51+
# NOTE: Used by apply-config.sh
52+
ENV APPLY_CONFIG__SOURCE_DIRECTORY=/code/build/
53+
ENV APPLY_CONFIG__DESTINATION_DIRECTORY=/usr/share/nginx/html/
54+
ENV APPLY_CONFIG__OVERWRITE_DESTINATION=true

docker-compose.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: ${COMPOSE_PROJECT_NAME:-ncrs-cms}
2+
3+
services:
4+
react:
5+
build:
6+
context: ../
7+
target: dev
8+
command: sh -c 'pnpm install --frozen-lockfile && pnpm run dev --host'
9+
volumes:
10+
- ../:/code
11+
ports:
12+
- "${PORT:-3000}:${PORT:-3000}"
13+
environment:
14+
- PORT=${PORT:-3000}
15+
- APP_TITLE=${APP_TITLE:-Nepal Red Cross Society CMS}
16+
- APP_GRAPHQL_ENDPOINT=${APP_GRAPHQL_ENDPOINT:-http://web:8000/graphql/}
17+
- APP_GRAPHQL_CODEGEN_ENDPOINT=${APP_GRAPHQL_CODEGEN_ENDPOINT:-./backend/schema.graphql}
18+
env_file:
19+
- .env
20+
depends_on:
21+
- web

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
"dev": "vite",
88
"build": "tsc -b && vite build",
99
"lint": "eslint .",
10-
"lint:css": "stylelint \"./src/**/*.css\"",
10+
"lint:css": "stylelint \"./app/**/*.css\"",
1111
"preview": "vite preview",
1212
"generate:type": "graphql-codegen --require dotenv/config --config codegen.ts",
1313
"knip": "knip"
1414
},
1515
"dependencies": {
16+
"@ifrc-go/ui": "^1.3.0",
1617
"@togglecorp/fujs": "^2.2.0",
1718
"graphql": "^16.12.0",
1819
"react": "^19.2.0",
@@ -71,5 +72,7 @@
7172
"overrides": {
7273
"vite": "npm:rolldown-vite@7.2.5"
7374
}
74-
}
75+
},
76+
"packageManager": "pnpm@8.15.9"
77+
7578
}

0 commit comments

Comments
 (0)