forked from Apillon/ps-signup-email-airdrop
-
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.
Merge pull request #22 from Apillon/staging
Staging
- Loading branch information
Showing
56 changed files
with
967 additions
and
255 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,38 @@ | ||
name: Deploy Website | ||
|
||
on: | ||
push: | ||
branches: | ||
- staging | ||
|
||
defaults: | ||
run: | ||
working-directory: ./frontend | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Build application | ||
run: npm run generate | ||
|
||
- name: Deploy website | ||
env: | ||
APILLON_API_KEY: ${{ secrets.APILLON_API_KEY }} | ||
APILLON_API_SECRET: ${{ secrets.APILLON_API_SECRET }} | ||
WEBSITE_UUID: ${{ secrets.WEBSITE_UUID_STAGING }} | ||
run: | | ||
npm i -g @apillon/cli | ||
apillon hosting deploy-website ./.output/public --uuid $WEBSITE_UUID --key $APILLON_API_KEY --secret $APILLON_API_SECRET |
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,38 @@ | ||
name: Deploy production Website | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
defaults: | ||
run: | ||
working-directory: ./frontend | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Build application | ||
run: npm run generate | ||
|
||
- name: Deploy website | ||
env: | ||
APILLON_API_KEY: ${{ secrets.APILLON_API_KEY }} | ||
APILLON_API_SECRET: ${{ secrets.APILLON_API_SECRET }} | ||
WEBSITE_UUID: ${{ secrets.WEBSITE_UUID }} | ||
run: | | ||
npm i -g @apillon/cli | ||
apillon hosting deploy-website ./.output/public --uuid $WEBSITE_UUID --key $APILLON_API_KEY --secret $APILLON_API_SECRET |
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,31 @@ | ||
#!/bin/sh | ||
|
||
if [ "$#" -ne 4 ]; then | ||
echo "Usage: $0 <database_host> <database_name> <mysql_user> <mysql_password>" | ||
exit 1 | ||
fi | ||
|
||
DATABASE_HOST=$1 | ||
DATABASE_NAME=$2 | ||
MYSQL_USER=$3 | ||
MYSQL_PASSWORD=$4 | ||
|
||
echo "Connecting to host: $DATABASE_HOST" | ||
ping -c 3 $DATABASE_HOST | ||
|
||
export MYSQL_PWD=$MYSQL_PASSWORD | ||
|
||
# Check if the database exists | ||
DB_EXISTS=$(mysql -h $DATABASE_HOST -u $MYSQL_USER -e "SHOW DATABASES LIKE '$DATABASE_NAME';" | grep "$DATABASE_NAME") | ||
|
||
if [ "$DB_EXISTS" == "$DATABASE_NAME" ]; then | ||
echo "Database $DATABASE_NAME already exists. Exiting." | ||
exit 0 | ||
fi | ||
|
||
# Create the database | ||
mysql -h $DATABASE_HOST -u $MYSQL_USER -e "CREATE DATABASE $DATABASE_NAME;" | ||
|
||
unset MYSQL_PWD | ||
|
||
echo "Database $DATABASE_NAME created successfully." |
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,14 @@ | ||
#!/bin/sh | ||
printenv | ||
|
||
echo "Waiting 1m for DB image to start" | ||
sleep 1m | ||
|
||
echo "Crating database..." | ||
./bin/create-database.sh "$MYSQL_HOST" "$MYSQL_DB" "$MYSQL_USER" "$MYSQL_PASSWORD" | ||
|
||
# migrate DB | ||
echo "Starting migration!" | ||
npm run db-upgrade:ci | ||
|
||
pm2 start pm2.config.js --attach |
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,4 @@ | ||
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/i0e4n2k8 | ||
docker build -t ment-airdrop:beta.0 . | ||
docker tag ment-airdrop:beta.0 public.ecr.aws/i0e4n2k8/ment-airdrop:beta.0 | ||
docker push public.ecr.aws/i0e4n2k8/ment-airdrop:beta.0 |
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,4 @@ | ||
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/i0e4n2k8 | ||
docker build -t ment-airdrop:latest . | ||
docker tag ment-airdrop:latest public.ecr.aws/i0e4n2k8/ment-airdrop:latest | ||
docker push public.ecr.aws/i0e4n2k8/ment-airdrop:latest |
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,47 @@ | ||
version: '3.8' | ||
|
||
services: | ||
airdrop_db: | ||
image: mysql | ||
container_name: airdrop_db | ||
env_file: | ||
- .env.sql.deploy | ||
# environment: | ||
# MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} | ||
# MYSQL_DATABASE: ${MYSQL_DATABASE} | ||
ports: | ||
- '3306:3306' | ||
restart: always | ||
volumes: | ||
- mysql-data:/var/lib/mysql | ||
|
||
airdrop_app: | ||
image: public.ecr.aws/i0e4n2k8/ment-airdrop:beta.0 | ||
container_name: airdrop_app | ||
depends_on: | ||
- airdrop_db | ||
env_file: | ||
- .env.deploy | ||
# environment: | ||
# APP_SECRET: ${APP_SECRET} | ||
# APP_URL: ${APP_URL} | ||
# ADMIN_WALLET: ${ADMIN_WALLET} | ||
# APILLON_KEY: ${APILLON_KEY} | ||
# APILLON_SECRET: ${APILLON_SECRET} | ||
# COLLECTION_UUID: ${COLLECTION_UUID} | ||
# SMTP_HOST: ${SMTP_HOST} | ||
# SMTP_PORT: ${SMTP_PORT} | ||
# SMTP_USERNAME: ${SMTP_USERNAME} | ||
# SMTP_PASSWORD: ${SMTP_PASSWORD} | ||
# SMTP_EMAIL_FROM: ${SMTP_EMAIL_FROM} | ||
# SMTP_NAME_FROM: ${SMTP_NAME_FROM} | ||
# API_HOST: ${API_HOST} | ||
# API_PORT: ${API_PORT} | ||
# CAPTCHA_SECRET: ${CAPTCHA_SECRET} | ||
# CLAIM_EXPIRES_IN: ${CLAIM_EXPIRES_IN} | ||
ports: | ||
- '8080:${API_PORT}' | ||
restart: always | ||
|
||
volumes: | ||
mysql-data: |
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,43 @@ | ||
services: | ||
proxy: | ||
image: nginxproxy/nginx-proxy:latest | ||
container_name: nginx-proxy | ||
restart: unless-stopped | ||
ports: | ||
- "80:80" | ||
- "443:443" | ||
volumes: | ||
- /var/run/docker.sock:/tmp/docker.sock:ro | ||
- /app/certs:/etc/nginx/certs:ro | ||
# - /etc/nginx/vhost.d | ||
# - /usr/share/nginx/html | ||
- vhost:/etc/nginx/vhost.d | ||
- html:/usr/share/nginx/html | ||
environment: | ||
- HTTPS_METHOD=noredirect | ||
networks: | ||
- web | ||
|
||
proxy-ssl: | ||
image: nginxproxy/acme-companion | ||
container_name: acme-companion | ||
restart: unless-stopped | ||
volumes_from: | ||
- proxy | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock:ro | ||
- /app/certs:/etc/nginx/certs:rw | ||
- acme:/etc/acme.sh | ||
environment: | ||
- [email protected] | ||
networks: | ||
- web | ||
|
||
volumes: | ||
vhost: | ||
html: | ||
acme: | ||
|
||
networks: | ||
web: | ||
name: web |
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,36 @@ | ||
version: '3.8' | ||
|
||
services: | ||
airdrop_db: | ||
image: mysql | ||
container_name: airdrop_db | ||
env_file: | ||
- .env.sql.deploy | ||
ports: | ||
- '3306:3306' | ||
restart: always | ||
volumes: | ||
- mysql-data:/var/lib/mysql | ||
networks: | ||
- db | ||
|
||
airdrop_app: | ||
image: public.ecr.aws/i0e4n2k8/ment-airdrop:latest | ||
container_name: airdrop_app | ||
depends_on: | ||
- airdrop_db | ||
env_file: | ||
- .env.deploy | ||
restart: always | ||
networks: | ||
- web | ||
- db | ||
|
||
volumes: | ||
mysql-data: | ||
|
||
networks: | ||
db: | ||
web: | ||
name: web | ||
external: true |
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,51 @@ | ||
FROM node:20-alpine | ||
|
||
ENV APP_ENV=production | ||
ARG APP_SECRET | ||
#should be overriden | ||
ENV APP_URL=http://localhost:3000 | ||
ENV API_PORT=3000 | ||
|
||
ENV MYSQL_HOST=airdrop_db | ||
ENV MYSQL_PORT=3306 | ||
ENV MYSQL_DB=airdrop | ||
ENV MYSQL_USER=root | ||
ARG MYSQL_PASSWORD | ||
ENV MYSQL_POOL=5 | ||
|
||
ARG ADMIN_WALLET | ||
ARG APILLON_KEY | ||
ARG APILLON_SECRET | ||
ARG COLLECTION_UUID | ||
|
||
ARG SMTP_HOST | ||
ARG SMTP_PORT | ||
ARG SMTP_USERNAME | ||
ARG SMTP_PASSWORD | ||
ARG SMTP_EMAIL_FROM | ||
ARG SMTP_NAME_FROM | ||
|
||
RUN echo $MYSQL_HOST | ||
|
||
ENV appDir /app | ||
RUN mkdir -p /app | ||
|
||
WORKDIR ${appDir} | ||
|
||
# Install MySQL client | ||
RUN apk --no-cache add mysql-client | ||
|
||
RUN npm install -g typescript pm2@latest | ||
|
||
ADD ./package-lock.json ${appDir} | ||
ADD ./package.json ${appDir} | ||
ADD ./ ${appDir}/ | ||
|
||
RUN npm install | ||
RUN npm run build | ||
RUN mkdir -p ./dist/templates/mail/ | ||
RUN cp ./src/templates/mail/*.html ./dist/templates/mail/ | ||
|
||
EXPOSE 3000 | ||
RUN chmod +x ./bin/docker-start.sh ./bin/create-database.sh | ||
CMD ["./bin/docker-start.sh"] |
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
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,14 @@ | ||
module.exports = { | ||
apps: [ | ||
{ | ||
name: 'http-server', | ||
script: './dist/scripts/start-http.js', | ||
restart_delay: 3000, | ||
}, | ||
{ | ||
name: 'cron', | ||
script: './dist/scripts/start-cron.js', | ||
restart_delay: 3000, | ||
}, | ||
], | ||
}; |
Oops, something went wrong.