-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c9167a
commit 42b6227
Showing
6 changed files
with
176 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Ignore Flutter build outputs | ||
build/ | ||
.flutter/ | ||
.dart_tool/ | ||
.packages | ||
|
||
# Ignore node_modules if you have any | ||
node_modules/ | ||
|
||
# Ignore editor settings | ||
.idea/ | ||
.vscode/ | ||
*.iml | ||
|
||
# Ignore OS-specific files | ||
.DS_Store | ||
Thumbs.db | ||
|
||
# Ignore git files | ||
.git | ||
.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Deploy Frontend to VPS | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev-jeremy | ||
|
||
env: | ||
SSH_AUTH_SOCK: /tmp/ssh_agent.sock | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y sshpass expect rsync | ||
- name: Setup SSH passphrase | ||
env: | ||
SSH_PASSPHRASE: ${{ secrets.SSH_PASSPHRASE }} | ||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | ||
run: | | ||
ssh-agent -a $SSH_AUTH_SOCK > /dev/null | ||
echo 'echo $SSH_PASSPHRASE' > ~/.ssh_askpass && chmod +x ~/.ssh_askpass | ||
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | DISPLAY=None SSH_ASKPASS=~/.ssh_askpass ssh-add - >/dev/null | ||
echo "SSH key added" | ||
- name: Verify SSH Connection | ||
env: | ||
VPS_IP: ${{ secrets.VPS_IP }} | ||
run: | | ||
sshpass -p "${{ secrets.SSH_PASSPHRASE }}" ssh -o StrictHostKeyChecking=no docker@${VPS_IP} "echo Connection successful" | ||
- name: Install rsync on VPS | ||
env: | ||
VPS_IP: ${{ secrets.VPS_IP }} | ||
run: | | ||
sshpass -p "${{ secrets.SSH_PASSPHRASE }}" ssh -o StrictHostKeyChecking=no docker@${VPS_IP} << 'EOF' | ||
sudo apt-get update | ||
sudo apt-get install -y rsync | ||
EOF | ||
- name: Copy files to VPS | ||
env: | ||
VPS_IP: ${{ secrets.VPS_IP }} | ||
run: | | ||
sshpass -p "${{ secrets.SSH_PASSPHRASE }}" rsync -avz -e "ssh -o StrictHostKeyChecking=no" ./ docker@${VPS_IP}:/frontend | ||
echo "Files copied to VPS" | ||
- name: SSH and run Docker Compose | ||
env: | ||
VPS_IP: ${{ secrets.VPS_IP }} | ||
run: | | ||
sshpass -p "${{ secrets.SSH_PASSPHRASE }}" ssh -o StrictHostKeyChecking=no docker@${VPS_IP} << 'EOF' | ||
cd /frontend | ||
docker-compose down | ||
docker-compose up -d --build | ||
echo "Docker Compose executed" | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Stage 1: Build the Flutter web project | ||
FROM cirrusci/flutter:3.10.6 as build | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Copy the Flutter project files | ||
COPY . . | ||
|
||
# Ensure dependencies are installed | ||
RUN flutter pub get | ||
|
||
# Build the project for web | ||
RUN flutter build web --release | ||
|
||
# Stage 2: Serve the static files with nginx | ||
FROM nginx:stable-alpine | ||
|
||
# Copy the built files from the previous stage | ||
COPY --from=build /app/build/web /usr/share/nginx/html | ||
|
||
# Change the default nginx port to 3000 | ||
RUN sed -i 's/listen .*/listen 3000;/' /etc/nginx/conf.d/default.conf | ||
|
||
# Expose the new port | ||
EXPOSE 3000 | ||
|
||
# Start nginx server | ||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
ifneq (,$(wildcard ./.env)) | ||
include .env | ||
export | ||
ENV_FILE_PARAM = --env-file .env | ||
|
||
endif | ||
|
||
build: | ||
docker-compose up -d --build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: '3.8' | ||
|
||
services: | ||
flutter-web: | ||
build: . | ||
ports: | ||
- "3000:3000" | ||
restart: always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters