diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..b564b4f --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,14 @@ +name: Portfolio App Deployment +run-name: ${{ gitea.actor }} is deploying Portfolio App +on: + push: + branches: + - main + +jobs: + Portfolio Runner: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - run: docker compose up -d --build diff --git a/.gitea/workflows/testing.yaml b/.gitea/workflows/testing.yaml new file mode 100644 index 0000000..f3383df --- /dev/null +++ b/.gitea/workflows/testing.yaml @@ -0,0 +1,13 @@ +name: Portfolio App Testing +run-name: ${{ gitea.actor }} is testing Portfolio App +on: [push] + +jobs: + Portfolio Runner: + runs-on: ubuntu-latest + steps: + - run: docker --version + - run: docker compose version + - name: Check out repository code + uses: actions/checkout@v4 + # Run tests diff --git a/Dockerfile b/Dockerfile index 21c6c7d..882064a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,20 +13,19 @@ RUN apt-get update && \ # If root adds files, it takes ownership, making them unremovable on the host except by using sudo # node tranfers ownership to the host user USER node -# EXPOSE 4200 CMD ["tail","-f","/dev/null"] #--- Building -# FROM base AS build -# COPY package*.json ./ -# RUN npm install -# # Copied here, since the the Development setup uses a bind volume instead -# COPY . . -# RUN ng build --configuration production +FROM base AS build +COPY package*.json ./ +RUN npm install +# Copied here, since the the Development setup uses a bind volume instead +COPY . . +RUN ng build --configuration production #--- Production -# FROM nginx:alpine AS production -# COPY --from=build /app/dist/quiz/browser /usr/share/nginx/html -# COPY nginx.conf /etc/nginx/conf.d/default.conf -# EXPOSE 80 -# CMD ["nginx", "-g", "daemon off;"] +FROM nginx:alpine AS production +COPY --from=build /app/dist/portfolio/browser /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a056f8f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +services: + frontend: + build: + context: . + dockerfile: Dockerfile + target: production + image: website-frontend-prod + container_name: website-frontend-prod-cont + ports: + - "4400:80" + restart: always + cpu_period: 100000 # Default is 100,000 microseconds (100ms) + cpu_quota: 5000 # 5% of the total CPU time \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..b2503a1 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,9 @@ +server { + listen 80; + + location / { + root /usr/share/nginx/html; + index index.html; + try_files $uri $uri/ /index.html; + } +} \ No newline at end of file