Skip to content

Commit

Permalink
feat: dockerize angular
Browse files Browse the repository at this point in the history
  • Loading branch information
KonsumGandalf committed Apr 27, 2024
1 parent 8e4e5e4 commit 93c585a
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 43 deletions.
22 changes: 22 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Ignore files and directories generated by npm or yarn
node_modules
npm-debug.log
yarn-error.log

# Ignore build artifacts and temporary files
/dist
/tmp
/out-tsc
#/**/*.d.ts

# Ignore development-specific files
*.md
/Deliverables
/Documentation

# Ignore version control files
.git

# Ignore Docker-specific files
.dockerignore
docker-compose.yml
42 changes: 0 additions & 42 deletions .github/workflows/ci.yml

This file was deleted.

18 changes: 18 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
on:
push:
branches:
- develop

permissions:
contents: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v4
with:
release-type: node
package-name: xcelerator-demo
target-branch: main
33 changes: 33 additions & 0 deletions apps/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM node:20-alpine as base

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

WORKDIR /usr/src/app

RUN corepack prepare pnpm@8.15.1 --activate

FROM base as installer

COPY package.json ./
COPY pnpm-lock.yaml ./

RUN pnpm install --frozen-lockfile

FROM base as builder

ENV NX_DEAMON="false"

COPY --from=installer /usr/src/app/node_modules ./node_modules

COPY . .

RUN pnpm nx build frontend

FROM nginx:stable-alpine as production

COPY apps/frontend/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /usr/src/app/dist/apps/frontend /usr/share/nginx/html

EXPOSE 80
26 changes: 26 additions & 0 deletions apps/frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Gzip Settings
gzip on;
gzip_disable “MSIE [1-6]\.(?!.*SV1)”;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 32 16k;
gzip_http_version 1.1;
gzip_min_length 250;
gzip_types image/jpeg image/bmp image/svg+xml text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon;

# security headers
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;

server {

listen 80;
root /usr/share/nginx/html;
autoindex on;

location / {
try_files $uri $uri/ /index.html =404;
}

}
6 changes: 6 additions & 0 deletions apps/frontend/proxy.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"/api": {
"target": "http://localhost:3000",
"secure": false
}
}
6 changes: 6 additions & 0 deletions apps/frontend/proxy.dev.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"/api": {
"target": "http://localhost:3000",
"secure": true
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"npm": ">=9.x.x"
},
"scripts": {
"prepare": "husky install",
"prepare": "if [[ $NODE_ENVIRONMENT != \"production\" ]]; then husky install; fi",
"lint-staged": "lint-staged",
"pre-commit": "lint-staged"
},
Expand Down

0 comments on commit 93c585a

Please sign in to comment.