Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
.git
.expo
dist
coverage
android
ios
graphify-out
spike-screenshots
113 changes: 113 additions & 0 deletions .github/workflows/pwa-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: PWA Deploy

on:
push:
branches:
- main
paths:
- 'app.config.ts'
- 'package.json'
- 'pnpm-lock.yaml'
- 'src/**'
- 'Dockerfile.web'
- 'Dockerfile.web.nginx.conf'
- '.github/workflows/pwa-deploy.yml'
workflow_dispatch:

permissions:
contents: read
packages: write

env:
IMAGE: ghcr.io/assrepdevelopment/mobile-pwa
APP_ENV: stage
API_BASE_URL: https://api.ass-rep-development.ru/api
PWA_URL: https://app.ass-rep-development.ru/

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GHCR_PAT }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.web
push: true
tags: |
${{ env.IMAGE }}:${{ github.sha }}
${{ env.IMAGE }}:latest
build-args: |
APP_ENV=${{ env.APP_ENV }}
API_BASE_URL=${{ env.API_BASE_URL }}
SENTRY_DSN=${{ secrets.SENTRY_DSN_STAGING }}

deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Deploy via SSH
uses: appleboy/ssh-action@v1.0.3
env:
IMAGE: ${{ env.IMAGE }}:${{ github.sha }}
GHCR_USER: ${{ secrets.GHCR_USER }}
GHCR_PAT: ${{ secrets.GHCR_PAT }}
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
envs: IMAGE,GHCR_USER,GHCR_PAT
script: |
set -euo pipefail
docker login ghcr.io -u "$GHCR_USER" -p "$GHCR_PAT"
docker pull "$IMAGE"
docker stop mobile-pwa 2>/dev/null || true
docker rm mobile-pwa 2>/dev/null || true
docker run -d \
--name mobile-pwa \
--restart unless-stopped \
-p 127.0.0.1:3001:80 \
"$IMAGE"

- name: Smoke check on staging host tunnel endpoint
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
set -euo pipefail
code="$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:3001)"
if [ "$code" != "200" ]; then
echo "Expected 200 from local container endpoint, got $code"
exit 1
fi

- name: Smoke check public PWA URL
run: |
set -euo pipefail
for i in $(seq 1 30); do
code="$(curl -s -o /dev/null -w "%{http_code}" "${PWA_URL}")"
if [ "$code" = "200" ]; then
echo "✅ PWA доступна на ${PWA_URL}"
exit 0
fi
sleep 10
done
echo "❌ PWA недоступна после 5 минут"
exit 1
20 changes: 20 additions & 0 deletions Dockerfile.web
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# syntax=docker/dockerfile:1
FROM node:20-alpine AS builder
WORKDIR /app
RUN corepack enable
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
COPY . .

ARG APP_ENV=stage
ARG API_BASE_URL=https://api.ass-rep-development.ru/api
ARG SENTRY_DSN=
ENV APP_ENV=$APP_ENV API_BASE_URL=$API_BASE_URL SENTRY_DSN=$SENTRY_DSN

RUN pnpm exec expo export --platform web

FROM nginx:alpine AS runtime
COPY --from=builder /app/dist /usr/share/nginx/html
COPY Dockerfile.web.nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
26 changes: 26 additions & 0 deletions Dockerfile.web.nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;

location / {
try_files $uri $uri/ /index.html;
}

location ~* \.(js|css|woff2?|ttf|otf|eot|svg|png|jpg|jpeg|gif|webp|ico)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}

location = /manifest.webmanifest {
add_header Cache-Control "no-cache";
}

location ~ ^/(service-worker\.js|sw\.js)$ {
add_header Cache-Control "no-cache, no-store, must-revalidate";
}

add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
}
Loading