-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from JuribaDev/add-docker-files
add docker files and some libraries
- Loading branch information
Showing
8 changed files
with
2,139 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ on: | |
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
actions: read | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Build stage | ||
FROM docker.io/node:lts-alpine3.20 AS build | ||
WORKDIR /app | ||
COPY package*.json ./ | ||
RUN npm ci | ||
COPY . . | ||
RUN npm run build -- --prod | ||
|
||
# Production stage | ||
FROM nginx:stable-alpine | ||
COPY --from=build /app/dist/client /usr/share/nginx/html | ||
COPY nginx.conf /etc/nginx/nginx.conf | ||
RUN chown -R nginx:nginx /usr/share/nginx/html && chmod -R 755 /usr/share/nginx/html && \ | ||
chown -R nginx:nginx /var/cache/nginx && \ | ||
chown -R nginx:nginx /var/log/nginx && \ | ||
chown -R nginx:nginx /etc/nginx/conf.d | ||
RUN touch /var/run/nginx.pid && \ | ||
chown -R nginx:nginx /var/run/nginx.pid | ||
USER nginx | ||
EXPOSE 80 | ||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
user nginx; | ||
worker_processes auto; | ||
|
||
error_log /var/log/nginx/error.log warn; | ||
pid /var/run/nginx.pid; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
access_log /var/log/nginx/access.log main; | ||
|
||
sendfile on; | ||
tcp_nopush on; | ||
tcp_nodelay on; | ||
keepalive_timeout 65; | ||
types_hash_max_size 2048; | ||
|
||
server { | ||
listen 80; | ||
server_name localhost; | ||
root /usr/share/nginx/html; | ||
index index.html index.htm; | ||
|
||
location / { | ||
try_files $uri $uri/ /index.html; | ||
} | ||
|
||
add_header X-Frame-Options "SAMEORIGIN" always; | ||
add_header X-XSS-Protection "1; mode=block" always; | ||
add_header X-Content-Type-Options "nosniff" always; | ||
add_header Referrer-Policy "no-referrer-when-downgrade" always; | ||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self' http://localhost:3000;" always; | ||
|
||
gzip on; | ||
gzip_vary on; | ||
gzip_proxied any; | ||
gzip_comp_level 6; | ||
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Build stage | ||
FROM docker.io/node:lts-alpine3.20 AS build | ||
WORKDIR /app | ||
COPY package*.json ./ | ||
RUN npm ci | ||
COPY . . | ||
RUN npm run build | ||
|
||
# Production stage | ||
FROM nginx:stable-alpine | ||
RUN apk add --no-cache dumb-init | ||
ENV NODE_ENV production | ||
WORKDIR /app | ||
COPY --from=build /app/node_modules ./node_modules | ||
COPY --from=build /app/dist ./dist | ||
RUN addgroup -g 1001 -S nodejs | ||
RUN adduser -S nestjs -u 1001 | ||
RUN chown -R nestjs:nodejs /app | ||
USER nestjs | ||
EXPOSE 3000 | ||
CMD ["dumb-init", "node", "dist/main"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.