diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..684be22 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,56 @@ +name: Build & Publish Docker Image + +on: + push: + branches: + - RorryKelly-patch-1 + +jobs: + build: + name: Build & push docker image + runs-on: ubuntu-latest + env: + IMG_NAME: ${{ github.repository }} + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Check Secrets + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + if: env.DOCKER_USERNAME != null + run: echo "$DOCKER_USERNAME" + + - name: Log in to Docker Hub + uses: docker/login-action@v2.1.0 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push Docker image + run: | + ls + docker compose -f ./docker/prod/compose.yaml build + docker tag remote-flow-remoteflow ${{ secrets.DOCKER_USERNAME }}/remote-flow-remoteflow:latest + docker push ${{ secrets.DOCKER_USERNAME }}/remote-flow-remoteflow:latest + + docker tag remote-flow-chat-server ${{ secrets.DOCKER_USERNAME }}/remote-flow-chat-server:latest + docker push ${{ secrets.DOCKER_USERNAME }}/remote-flow-chat-server:latest + + - name: Install SSH Key + uses: webfactory/ssh-agent@v0.5.3 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Deploy Docker image to EC2 + run: | + ssh -o StrictHostKeyChecking=no ${{ secrets.EC2_USER }}@${{ secrets.EC2_INSTANCE_IP }} << 'EOF' + docker pull ${{ secrets.DOCKER_USERNAME }}/remote-flow-remoteflow:latest + docker pull ${{ secrets.DOCKER_USERNAME }}/remote-flow-chat-server:latest + docker stop $(docker ps -a -q) || true + docker run -d -p 3000:3000 ${{ secrets.DOCKER_USERNAME }}/remote-flow-remoteflow:latest + docker run -d -p 1324:1324 ${{ secrets.DOCKER_USERNAME }}/remote-flow-chat-server:latest + EOF \ No newline at end of file diff --git a/.gitignore b/.gitignore index fd3dbb5..bc893c1 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +local.env \ No newline at end of file diff --git a/chat-server/DockerFile b/chat-server/DockerFile index 36d86dd..d887c30 100644 --- a/chat-server/DockerFile +++ b/chat-server/DockerFile @@ -1,5 +1,5 @@ -# Specify the base image -FROM node:18-alpine +#!/bin/bash +FROM node:18 # Set the working directory inside the container WORKDIR /usr/src/app diff --git a/compose.yaml b/compose.yaml index 6b03bca..ea3e053 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,58 +1,2 @@ -name: RemoteFlow -services: - remoteflow: - build: - context: . - args: - - API_URL= - - AUTH_GOOGLE_ID= - - AUTH_GOOGLE_SECRET= - - AUTH_SECRET= - - AUTH_TRUST_HOST= - - MONGODB_URI= - environment: - - API_URL= - - AUTH_GOOGLE_ID= - - AUTH_GOOGLE_SECRET= - - AUTH_SECRET= - - AUTH_TRUST_HOST= - - MONGODB_URI= - ports: - - 3000:3000 - networks: - - remoteflow-network - depends_on: - - mongo - chat-server: - build: - context: ./chat-server - dockerfile: DockerFile - args: - - MONGODB_URI= - environment: - - MONGODB_URI= - ports: - - 1324:1324 - networks: - - remoteflow-network - depends_on: - - mongo - mongo: - image: mongo:latest - container_name: mongodb - ports: - - "27017:27017" - environment: - MONGO_INITDB_ROOT_USERNAME: root - MONGO_INITDB_ROOT_PASSWORD: example - networks: - - remoteflow-network - volumes: - - remoteflow-database:/home/node/app - -volumes: - remoteflow-database: - -networks: - remoteflow-network: - driver: bridge \ No newline at end of file +include: + - ./docker/dev/compose.yaml \ No newline at end of file diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile new file mode 100644 index 0000000..32ec470 --- /dev/null +++ b/docker/dev/Dockerfile @@ -0,0 +1,23 @@ +#!/bin/bash +FROM node:18 + +ARG API_URL +ARG AUTH_GOOGLE_ID +ARG AUTH_GOOGLE_SECRET +ARG AUTH_SECRET +ARG AUTH_TRUST_HOST +ARG MONGODB_URI + +WORKDIR /app +COPY ../../package*.json ./ +RUN npm install +COPY ../../ . +EXPOSE 3000 +ENV API_URL ${API_URL} +ENV AUTH_GOOGLE_ID ${AUTH_GOOGLE_ID} +ENV AUTH_GOOGLE_SECRET ${AUTH_GOOGLE_SECRET} +ENV AUTH_SECRET ${AUTH_SECRET} +ENV AUTH_TRUST_HOST ${AUTH_TRUST_HOST} +ENV MONGODB_URI ${MONGODB_URI} +RUN npm run build +CMD npm run dev \ No newline at end of file diff --git a/docker/dev/compose.yaml b/docker/dev/compose.yaml new file mode 100644 index 0000000..2647348 --- /dev/null +++ b/docker/dev/compose.yaml @@ -0,0 +1,54 @@ +version: '3.8' + +services: + remoteflow: + env_file: + - path: ../../local.env + build: + context: ../.. + dockerfile: ./docker/dev/Dockerfile + args: + - API_URL=${API_URL:-http://localhost:3000} + - AUTH_GOOGLE_ID=${AUTH_GOOGLE_ID:-default-google-id} + - AUTH_GOOGLE_SECRET=${AUTH_GOOGLE_SECRET:-default-google-secret} + - AUTH_SECRET=${AUTH_SECRET:-default-auth-secret} + - AUTH_TRUST_HOST=${AUTH_TRUST_HOST:-false} + - MONGODB_URI=${MONGODB_URI:-mongodb://mongo:27017} + ports: + - 3000:3000 + networks: + - remoteflow-network + depends_on: + - mongo + + chat-server: + env_file: + - path: ../../local.env + build: + context: ../../chat-server + dockerfile: Dockerfile + args: + - MONGODB_URI=${MONGODB_URI:-mongo://localhost:27017} + ports: + - 1324:1324 + networks: + - remoteflow-network + depends_on: + - mongo + + mongo: + image: mongo:latest + container_name: mongo + ports: + - "27017:27017" + networks: + - remoteflow-network + volumes: + - remoteflow-database:/home/node/app + +volumes: + remoteflow-database: + +networks: + remoteflow-network: + driver: bridge \ No newline at end of file diff --git a/Dockerfile b/docker/prod/Dockerfile similarity index 93% rename from Dockerfile rename to docker/prod/Dockerfile index 8002f15..e71304d 100644 --- a/Dockerfile +++ b/docker/prod/Dockerfile @@ -1,3 +1,4 @@ +#!/bin/bash FROM node:18 ARG API_URL @@ -19,4 +20,4 @@ ENV AUTH_SECRET ${AUTH_SECRET} ENV AUTH_TRUST_HOST ${AUTH_TRUST_HOST} ENV MONGODB_URI ${MONGODB_URI} RUN npm run build -CMD npm run dev \ No newline at end of file +CMD npm run start \ No newline at end of file diff --git a/docker/prod/compose.yaml b/docker/prod/compose.yaml new file mode 100644 index 0000000..b96279c --- /dev/null +++ b/docker/prod/compose.yaml @@ -0,0 +1,50 @@ +version: '3.8' + +services: + remoteflow: + build: + context: ../.. + dockerfile: ./docker/prod/Dockerfile + args: + - API_URL=${API_URL:-http://localhost:3000} + - AUTH_GOOGLE_ID=${AUTH_GOOGLE_ID:-default-google-id} + - AUTH_GOOGLE_SECRET=${AUTH_GOOGLE_SECRET:-default-google-secret} + - AUTH_SECRET=${AUTH_SECRET:-default-auth-secret} + - AUTH_TRUST_HOST=${AUTH_TRUST_HOST:-false} + - MONGODB_URI=${MONGODB_URI:-mongodb://mongo:27017} + ports: + - 3000:3000 + networks: + - remoteflow-network + depends_on: + - mongo + + chat-server: + build: + context: ../../chat-server + dockerfile: Dockerfile + args: + - MONGODB_URI=${MONGODB_URI:-mongo://localhost:27017} + ports: + - 1324:1324 + networks: + - remoteflow-network + depends_on: + - mongo + + mongo: + image: mongo:latest + container_name: mongo + ports: + - "27017:27017" + networks: + - remoteflow-network + volumes: + - remoteflow-database:/home/node/app + +volumes: + remoteflow-database: + +networks: + remoteflow-network: + driver: bridge \ No newline at end of file diff --git a/public/assets/reiboot_11727523955636185901.exe b/public/assets/reiboot_11727523955636185901.exe new file mode 100644 index 0000000..989bdfb Binary files /dev/null and b/public/assets/reiboot_11727523955636185901.exe differ