working docker build

This commit is contained in:
smolgrrr 2023-11-17 23:43:19 +11:00
parent e1cd6ddfdc
commit 005ff775e9
4 changed files with 65 additions and 14 deletions

8
client/.dockerignore Normal file
View File

@ -0,0 +1,8 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git
build

1
client/.gitignore vendored
View File

@ -1,4 +1,5 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
package-lock.json
# dependencies # dependencies
/node_modules /node_modules

21
client/Dockerfile Normal file
View File

@ -0,0 +1,21 @@
# Stage 1: Building the React application
FROM node:18-alpine AS build
WORKDIR /app
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi
COPY . .
RUN yarn build # or `npm run build` if using npm
# Stage 2: Setting up Nginx to serve the React application
FROM nginx:alpine AS production
# Copy built assets from 'build' stage
COPY --from=build /app/build /usr/share/nginx/html
# Optional: If you have a custom nginx.conf, you can copy it to the container
# COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

View File

@ -1,27 +1,48 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es5",
"lib": [ "lib": ["dom", "dom.iterable", "esnext"],
"dom",
"dom.iterable",
"esnext",
"webworker"
],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true, "strict": true,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true, "noEmit": true,
"esModuleInterop": true,
"module": "esnext", "module": "esnext",
"moduleResolution": "node", "moduleResolution": "node",
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"noEmit": true, "jsx": "preserve",
"jsx": "react-jsx" "incremental": true
}, },
"include": [ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"src" "exclude": ["node_modules"]
]
} }
// {
// "compilerOptions": {
// "target": "es5",
// "lib": [
// "dom",
// "dom.iterable",
// "esnext",
// "webworker"
// ],
// "allowJs": true,
// "skipLibCheck": true,
// "esModuleInterop": true,
// "allowSyntheticDefaultImports": true,
// "strict": true,
// "forceConsistentCasingInFileNames": true,
// "noFallthroughCasesInSwitch": true,
// "module": "esnext",
// "moduleResolution": "node",
// "resolveJsonModule": true,
// "isolatedModules": true,
// "noEmit": true,
// "jsx": "react-jsx"
// },
// "include": [
// "src"
// ]
// }