From 5dedadddf938714ed6512b24da9ebe148b6ef311 Mon Sep 17 00:00:00 2001 From: Luke Gustafson Date: Wed, 27 Nov 2024 01:07:44 +0000 Subject: [PATCH] Commit --- .github/workflows/docker-image.yml | 26 ++++++---- .../User/History/-75aa7516/YqrT.yml | 48 +++++++++++++++++++ .../User/History/-75aa7516/entries.json | 2 +- .../User/History/-75aa7516/jUoS.yml | 41 ++++++++++++++++ .../code-server/User/History/2e659bb2/EvMq | 23 +++++++++ .../User/History/2e659bb2/entries.json | 2 +- docker/Dockerfile | 37 ++++++-------- frontend/{src => }/package-lock.json | 0 frontend/{src => }/package.json | 0 9 files changed, 146 insertions(+), 33 deletions(-) create mode 100644 .local/share/code-server/User/History/-75aa7516/YqrT.yml create mode 100644 .local/share/code-server/User/History/-75aa7516/jUoS.yml create mode 100644 .local/share/code-server/User/History/2e659bb2/EvMq rename frontend/{src => }/package-lock.json (100%) rename frontend/{src => }/package.json (100%) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 3ab94469..7d503388 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -11,21 +11,30 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '18' - - name: Install dependencies and build frontend + - name: Install and Build Frontend run: | cd frontend npm install npm run build - ls -R . # Debugging: List files in frontend after build - - - name: Debug workspace structure - run: ls -R /github/workspace # Debugging: Verify where `dist` is created - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Set up Docker login to GHCR + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to Docker Registry (GHCR) uses: docker/login-action@v2 with: registry: ghcr.io @@ -33,8 +42,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build Docker image - run: | - docker build -f docker/Dockerfile . --tag ghcr.io/$REPO_NAME/ssh-project:$DATE_TAG + run: docker build -f Dockerfile -t ghcr.io/${{ github.repository_owner }}/ssh-project:${{ github.run_id }} . - name: Push Docker image to GHCR - run: docker push ghcr.io/$REPO_NAME/ssh-project:$DATE_TAG \ No newline at end of file + run: docker push ghcr.io/${{ github.repository_owner }}/ssh-project:${{ github.run_id }} \ No newline at end of file diff --git a/.local/share/code-server/User/History/-75aa7516/YqrT.yml b/.local/share/code-server/User/History/-75aa7516/YqrT.yml new file mode 100644 index 00000000..7d503388 --- /dev/null +++ b/.local/share/code-server/User/History/-75aa7516/YqrT.yml @@ -0,0 +1,48 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '18' + + - name: Install and Build Frontend + run: | + cd frontend + npm install + npm run build + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to Docker Registry (GHCR) + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Docker image + run: docker build -f Dockerfile -t ghcr.io/${{ github.repository_owner }}/ssh-project:${{ github.run_id }} . + + - name: Push Docker image to GHCR + run: docker push ghcr.io/${{ github.repository_owner }}/ssh-project:${{ github.run_id }} \ No newline at end of file diff --git a/.local/share/code-server/User/History/-75aa7516/entries.json b/.local/share/code-server/User/History/-75aa7516/entries.json index 45f4133b..5e778ebd 100644 --- a/.local/share/code-server/User/History/-75aa7516/entries.json +++ b/.local/share/code-server/User/History/-75aa7516/entries.json @@ -1 +1 @@ -{"version":1,"resource":"vscode-remote://coder.karmaashomepage.online/home/bugattiguy527/.github/workflows/docker-image.yml","entries":[{"id":"9X2e.yml","timestamp":1732667889336},{"id":"3EZP.yml","timestamp":1732667936044}]} \ No newline at end of file +{"version":1,"resource":"vscode-remote://coder.karmaashomepage.online/home/bugattiguy527/.github/workflows/docker-image.yml","entries":[{"id":"9X2e.yml","timestamp":1732667889336},{"id":"3EZP.yml","timestamp":1732667936044},{"id":"jUoS.yml","source":"undoRedo.source","timestamp":1732667990352},{"id":"YqrT.yml","timestamp":1732669649485}]} \ No newline at end of file diff --git a/.local/share/code-server/User/History/-75aa7516/jUoS.yml b/.local/share/code-server/User/History/-75aa7516/jUoS.yml new file mode 100644 index 00000000..0119f986 --- /dev/null +++ b/.local/share/code-server/User/History/-75aa7516/jUoS.yml @@ -0,0 +1,41 @@ +name: Build and Push Docker Image +on: + push: + branches: + - main +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Set up Docker login to GHCR + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Generate docker tag + id: prep + run: | + echo "REPO_NAME=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + echo "DATE_TAG=$(date +%s)" >> $GITHUB_ENV + + - name: Build Docker image + run: docker build -f docker/Dockerfile . --tag ghcr.io/$REPO_NAME/ssh-project:$DATE_TAG + + - name: Push Docker image to GHCR + run: docker push ghcr.io/$REPO_NAME/ssh-project:$DATE_TAG diff --git a/.local/share/code-server/User/History/2e659bb2/EvMq b/.local/share/code-server/User/History/2e659bb2/EvMq new file mode 100644 index 00000000..f5061495 --- /dev/null +++ b/.local/share/code-server/User/History/2e659bb2/EvMq @@ -0,0 +1,23 @@ +# Build frontend +FROM node:18-slim AS frontend-build +WORKDIR /app +COPY frontend/package*.json ./frontend/ +RUN npm --prefix frontend install +COPY frontend/ ./frontend/ +RUN npm --prefix frontend run build + +# Build backend +FROM node:18-slim AS backend-build +WORKDIR /backend +COPY backend/package*.json ./ +RUN npm install +COPY backend/ . + +# Production image +FROM nginx:alpine +# Copy frontend static files to nginx folder +COPY --from=frontend-build /app/frontend/dist /usr/share/nginx/html +# Copy backend application +COPY --from=backend-build /backend /backend +# Start backend and frontend servers +CMD ["sh", "-c", "node /backend/server.js & nginx -g 'daemon off;'"] \ No newline at end of file diff --git a/.local/share/code-server/User/History/2e659bb2/entries.json b/.local/share/code-server/User/History/2e659bb2/entries.json index d782ee58..5f06d3a2 100644 --- a/.local/share/code-server/User/History/2e659bb2/entries.json +++ b/.local/share/code-server/User/History/2e659bb2/entries.json @@ -1 +1 @@ -{"version":1,"resource":"vscode-remote://coder.karmaashomepage.online/home/bugattiguy527/docker/Dockerfile","entries":[{"id":"TUF1","timestamp":1732635492973},{"id":"8otg","timestamp":1732635506681},{"id":"XU8z","source":"undoRedo.source","timestamp":1732635515769},{"id":"ars1","timestamp":1732635532917},{"id":"8UPb","timestamp":1732635628577},{"id":"gWeB","timestamp":1732635658901},{"id":"Z5sv","source":"undoRedo.source","timestamp":1732635671649},{"id":"J4VB","timestamp":1732635674581},{"id":"eNc9","timestamp":1732651223530},{"id":"qz6w","timestamp":1732666102382},{"id":"dg9u","timestamp":1732666385636},{"id":"xeWT","timestamp":1732666594049},{"id":"VKz9","timestamp":1732666699486},{"id":"ohj0","timestamp":1732666756338},{"id":"YYfg","timestamp":1732666912166},{"id":"fk8j","source":"undoRedo.source","timestamp":1732666929490},{"id":"KzCQ","timestamp":1732666932302},{"id":"Ksxv","timestamp":1732666980583},{"id":"YyhO","timestamp":1732667021083},{"id":"fABD","timestamp":1732667045735},{"id":"9QEU","timestamp":1732667168771},{"id":"ZvDX","source":"undoRedo.source","timestamp":1732667172295},{"id":"b8fu","timestamp":1732667181363},{"id":"U8fB","timestamp":1732667377239},{"id":"qfRq","timestamp":1732667388987},{"id":"EPuH","timestamp":1732667567379},{"id":"ErcD","timestamp":1732667709908}]} \ No newline at end of file +{"version":1,"resource":"vscode-remote://coder.karmaashomepage.online/home/bugattiguy527/docker/Dockerfile","entries":[{"id":"TUF1","timestamp":1732635492973},{"id":"8otg","timestamp":1732635506681},{"id":"XU8z","source":"undoRedo.source","timestamp":1732635515769},{"id":"ars1","timestamp":1732635532917},{"id":"8UPb","timestamp":1732635628577},{"id":"gWeB","timestamp":1732635658901},{"id":"Z5sv","source":"undoRedo.source","timestamp":1732635671649},{"id":"J4VB","timestamp":1732635674581},{"id":"eNc9","timestamp":1732651223530},{"id":"qz6w","timestamp":1732666102382},{"id":"dg9u","timestamp":1732666385636},{"id":"xeWT","timestamp":1732666594049},{"id":"VKz9","timestamp":1732666699486},{"id":"ohj0","timestamp":1732666756338},{"id":"YYfg","timestamp":1732666912166},{"id":"fk8j","source":"undoRedo.source","timestamp":1732666929490},{"id":"KzCQ","timestamp":1732666932302},{"id":"Ksxv","timestamp":1732666980583},{"id":"YyhO","timestamp":1732667021083},{"id":"fABD","timestamp":1732667045735},{"id":"9QEU","timestamp":1732667168771},{"id":"ZvDX","source":"undoRedo.source","timestamp":1732667172295},{"id":"b8fu","timestamp":1732667181363},{"id":"U8fB","timestamp":1732667377239},{"id":"qfRq","timestamp":1732667388987},{"id":"EPuH","timestamp":1732667567379},{"id":"ErcD","timestamp":1732667709908},{"id":"EvMq","timestamp":1732669655605}]} \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 0454b285..f5061495 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,30 +1,23 @@ -FROM node:18-slim AS combined-build +# Build frontend +FROM node:18-slim AS frontend-build WORKDIR /app - -# Copy and install frontend dependencies COPY frontend/package*.json ./frontend/ -WORKDIR /app/frontend -RUN npm install -COPY frontend/ . -RUN npm run build +RUN npm --prefix frontend install +COPY frontend/ ./frontend/ +RUN npm --prefix frontend run build -# Copy frontend build output to /app directory -WORKDIR /app -RUN mkdir -p /app/public -COPY /app/dist /app/public - -# Setup backend +# Build backend +FROM node:18-slim AS backend-build +WORKDIR /backend COPY backend/package*.json ./ RUN npm install COPY backend/ . -# Setup Nginx to serve the React App +# Production image FROM nginx:alpine -COPY --from=combined-build /app/public /usr/share/nginx/html - -# Expose ports for frontend and backend -EXPOSE 80 -EXPOSE 3001 - -# Run backend and frontend servers -CMD ["sh", "-c", "node /app/src/components/server.js & nginx -g 'daemon off;'"] \ No newline at end of file +# Copy frontend static files to nginx folder +COPY --from=frontend-build /app/frontend/dist /usr/share/nginx/html +# Copy backend application +COPY --from=backend-build /backend /backend +# Start backend and frontend servers +CMD ["sh", "-c", "node /backend/server.js & nginx -g 'daemon off;'"] \ No newline at end of file diff --git a/frontend/src/package-lock.json b/frontend/package-lock.json similarity index 100% rename from frontend/src/package-lock.json rename to frontend/package-lock.json diff --git a/frontend/src/package.json b/frontend/package.json similarity index 100% rename from frontend/src/package.json rename to frontend/package.json