-
Notifications
You must be signed in to change notification settings - Fork 1
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 #9 from Star-Academy/fixcicd
fix: bug in dockerfile is fixed
- Loading branch information
Showing
4 changed files
with
153 additions
and
43 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: CD_Frontend | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
version-and-release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Bump version and push tag | ||
id: tag_version | ||
uses: mathieudutour/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: login to docker registry | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{secrets.DOCKERHUB_USERNAME}} | ||
password: ${{secrets.DOCKERHUB_TOKEN}} | ||
|
||
- name: build and push docker backend to registry | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: Dockerfile | ||
push: true | ||
tags: mohammadsadeghmontazeri/starfront:latest | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.tag_version.outputs.new_tag }} | ||
release_name: Release ${{ steps.tag_version.outputs.new_tag }} | ||
body: | | ||
steps.tag_version.outputs.changelog | ||
draft: false | ||
prerelease: false |
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 |
---|---|---|
@@ -1,22 +1,12 @@ | ||
name: CI_Frontend | ||
#test pipeline | ||
permissions: | ||
contents: write | ||
packages: write | ||
issues: write | ||
pull-requests: write | ||
deployments: write | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
build-and-test: | ||
name: Build & Test | ||
runs-on: ubuntu-latest | ||
|
||
|
@@ -36,39 +26,9 @@ jobs: | |
run: npm ci | ||
working-directory: project | ||
|
||
#- name: Run Unit Tests | ||
# run: npm run test | ||
# working-directory: project | ||
- name: test in container | ||
run: docker build -t node-docker-image-test --no-cache --target test . | ||
|
||
- name: Build Application | ||
run: npm run build | ||
working-directory: project | ||
|
||
semantic-versioning: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Bump version and push tag | ||
id: tag_version | ||
uses: mathieudutour/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.tag_version.outputs.new_tag }} | ||
release_name: Release ${{ steps.tag_version.outputs.new_tag }} | ||
body: | | ||
content | ||
draft: false | ||
prerelease: false |
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,70 @@ | ||
# Stage 1: Base setup | ||
FROM node:20 AS base | ||
|
||
WORKDIR /app | ||
|
||
COPY /project/package*.json ./ | ||
|
||
RUN npm ci && npm install -g @angular/[email protected] | ||
|
||
# Install Google Chrome for headless testing | ||
RUN apt-get update && apt-get install -y \ | ||
wget \ | ||
gnupg2 \ | ||
&& wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \ | ||
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \ | ||
&& apt-get update \ | ||
&& apt-get install -y google-chrome-stable \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ENV CHROME_BIN="/usr/bin/google-chrome" | ||
|
||
# Stage 2: Test | ||
FROM base as test | ||
|
||
COPY /project/ . | ||
|
||
RUN ng lint --fix | ||
RUN ng lint | ||
|
||
RUN ng test --watch=false --browsers=ChromeHeadlessNoSandbox | ||
|
||
# Stage 3: Build | ||
FROM base as build | ||
|
||
COPY /project/ . | ||
|
||
RUN npm ci | ||
|
||
# Build both the client and server-side parts | ||
RUN npm run build | ||
|
||
|
||
FROM nginx:latest as nginx | ||
|
||
COPY nginx.conf /etc/nginx/nginx.conf | ||
|
||
# Copy static assets from the build | ||
COPY --from=build /app/dist/project/browser/ /usr/share/nginx/html/ | ||
|
||
|
||
|
||
# Stage 4: Server | ||
#FROM base AS server | ||
|
||
#WORKDIR /app | ||
|
||
# Copy the compiled server-side application from the build stage | ||
#COPY --from=build /app/dist/project/ /app/dist/ | ||
|
||
# Install only production dependencies | ||
#COPY /project/package*.json ./ | ||
#RUN npm ci --only=production | ||
|
||
#EXPOSE 4000 | ||
|
||
# Start the Node.js server to handle SSR | ||
#CMD ["node", "dist/server/server.mjs"] | ||
|
||
|
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,31 @@ | ||
user nginx; | ||
pid /var/run/nginx.pid; | ||
worker_processes auto; | ||
|
||
events{ | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
|
||
server{ | ||
listen 80; | ||
sendfile on; | ||
default_type application/octet-stream; | ||
|
||
gzip on; | ||
gzip_http_version 1.1; | ||
gzip_disable "MSIE [1-6]\."; | ||
gzip_min_length 256; | ||
gzip_vary on; | ||
gzip_proxied expired no-cache no-store private auth; | ||
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; | ||
gzip_comp_level 9; | ||
|
||
root /usr/share/nginx/html; | ||
index index.csr.html; | ||
location / { | ||
try_files $uri $uri/ /index.csr.html =404; | ||
} | ||
} | ||
} |