aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/docker-backend.yml32
-rw-r--r--.github/workflows/docker-frontend.yml2
-rw-r--r--backend/Dockerfile13
-rw-r--r--frontend/Dockerfile10
4 files changed, 56 insertions, 1 deletions
diff --git a/.github/workflows/docker-backend.yml b/.github/workflows/docker-backend.yml
new file mode 100644
index 0000000..f355e65
--- /dev/null
+++ b/.github/workflows/docker-backend.yml
@@ -0,0 +1,32 @@
+name: Deploy backend to AWS
+
+on:
+ workflow_dispatch:
+
+jobs:
+ deploy:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Configure AWS credentials
+ uses: aws-actions/configure-aws-credentials@v1
+ with:
+ aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
+ aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
+ aws-region: eu-west-1
+
+ - name: Login to Amazon ECR
+ id: login-ecr
+ uses: aws-actions/amazon-ecr-login@v1
+
+ - name: Build & push backend Docker image
+ env:
+ ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
+ ECR_REPOSITORY: tetris
+ IMAGE_TAG: backend
+ run: |
+ cd backend
+ docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
+ docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
diff --git a/.github/workflows/docker-frontend.yml b/.github/workflows/docker-frontend.yml
index 17b84c0..2a0bbd6 100644
--- a/.github/workflows/docker-frontend.yml
+++ b/.github/workflows/docker-frontend.yml
@@ -1,4 +1,4 @@
-name: AWS Deployment
+name: Deploy frontend to AWS
on:
workflow_dispatch:
diff --git a/backend/Dockerfile b/backend/Dockerfile
new file mode 100644
index 0000000..218cc8d
--- /dev/null
+++ b/backend/Dockerfile
@@ -0,0 +1,13 @@
+FROM node:18
+
+WORKDIR /app
+
+COPY package.json ./
+
+RUN npm install
+
+COPY . .
+
+EXPOSE 3000
+
+CMD ["npm", "start"] \ No newline at end of file
diff --git a/frontend/Dockerfile b/frontend/Dockerfile
index 723e97e..0f96ba3 100644
--- a/frontend/Dockerfile
+++ b/frontend/Dockerfile
@@ -8,6 +8,16 @@ RUN npm install
COPY . .
+ARG BACKEND_HTTP_URL
+ENV VITE_BACKEND_BASE_URL ${BACKEND_HTTP_URL}
+
+ARG BACKEND_WS_URL
+ENV VITE_BACKEND_WS_URL ${BACKEND_WS_URL}
+
+ARG FRONTEND_URL
+ENV VITE_FRONTEND_BASE_URL ${FRONTEND_URL}
+
+
RUN npm run build