-
Notifications
You must be signed in to change notification settings - Fork 10
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
s1lvax
committed
Oct 10, 2024
1 parent
bb743ca
commit 2dc2287
Showing
5 changed files
with
201 additions
and
5 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,45 @@ | ||
name: Deploy App | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # or your deployment branch | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Copy repository to SFTP | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.SFTP_HOST }} | ||
username: ${{ secrets.SFTP_USER }} | ||
password: ${{ secrets.SFTP_PASSWORD }} | ||
port: ${{ secrets.SFTP_PORT }} | ||
source: '.' | ||
target: '/opt/route' | ||
|
||
- name: Build and deploy Docker container | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SFTP_HOST }} | ||
username: ${{ secrets.SFTP_USER }} | ||
password: ${{ secrets.SFTP_PASSWORD }} | ||
port: ${{ secrets.SFTP_PORT }} | ||
script: | | ||
cd '/opt/route' | ||
# Overwrite the .env file to recreate it during each deployment | ||
echo "AUTH_SECRET=${{ secrets.AUTH_SECRET }}" > .env | ||
echo "CLIENT_ID=${{ secrets.CLIENT_ID }}" >> .env | ||
echo "CLIENT_SECRET=${{ secrets.CLIENT_SECRET }}" >> .env | ||
echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" >> .env | ||
docker build -t route . | ||
docker stop route || true | ||
docker rm route || true | ||
docker run -d --name route --restart always -p 3002:3000 route |
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,33 @@ | ||
# Builder stage | ||
FROM node:21-alpine AS builder | ||
WORKDIR /app | ||
|
||
# Install pnpm | ||
RUN npm install -g pnpm | ||
|
||
# Copy package files and install dependencies | ||
COPY package*.json ./ | ||
RUN pnpm install | ||
|
||
# Copy the rest of the files and build the application | ||
COPY . . | ||
RUN pnpm run build | ||
|
||
# Prune development dependencies | ||
RUN pnpm prune --prod | ||
|
||
# Final stage | ||
FROM node:21-alpine | ||
WORKDIR /app | ||
|
||
# Copy necessary files from builder stage | ||
COPY --from=builder /app/build build/ | ||
COPY --from=builder /app/node_modules node_modules/ | ||
COPY package.json . | ||
|
||
# Set the environment and expose the port | ||
EXPOSE 3000 | ||
ENV NODE_ENV=production | ||
|
||
# Command to run the application | ||
CMD [ "node", "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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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