Skip to content

Commit

Permalink
Merge pull request #9 from Star-Academy/fixcicd
Browse files Browse the repository at this point in the history
fix: bug in dockerfile is fixed
  • Loading branch information
msm1984 authored Aug 23, 2024
2 parents 37f5d44 + 5325d55 commit d27d3dd
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 43 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/CD_Frontend.yml
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
46 changes: 3 additions & 43 deletions .github/workflows/CI_Frontend.yml
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

Expand All @@ -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
70 changes: 70 additions & 0 deletions Dockerfile
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"]


31 changes: 31 additions & 0 deletions nginx.conf
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;
}
}
}

0 comments on commit d27d3dd

Please sign in to comment.