Skip to content

Commit

Permalink
Merge pull request #4 from Apillon/feature/docker
Browse files Browse the repository at this point in the history
docker fixes & docs
  • Loading branch information
MoMannn authored Apr 8, 2024
2 parents ca8c27f + 35ef4e5 commit 403d1a1
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 195 deletions.
23 changes: 23 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
node_modules
npm-debug.log
.npm
logs
*.log
tmp
.DS_Store
.git
.gitignore
README.md
LICENSE
.dockerignore
dockerfile
.nyc_output
.coverage
.vscode
*.md
*.yml
.env*
dist
*.tar
docker-compose.*
build-image.sh
76 changes: 76 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Pre-built solution for Sign-up Email Airdrop via Apillon API (backend)

//TODO: description

## Environment variables

For local development and running app you will need to configure some environment variables. List of all supported vars can be found in [`src/config/env.ts`](/src/config/env.ts).

For local development you should create `.env` file. To run this app in Docker, you can create `.env.deploy` and `.env.sql.deploy` and use provided [`docker-compose.yml`](/docker-compose.yml)

### .env

For running locally, create new `.env` file in project root folder (`backend/`) and set at least all the variables (probably with different values) as in `.env.deploy` file described bellow.

### .env.deploy

For running a docker image with [`docker-compose.yml`](/docker-compose.yml) you should create `.env.deploy` file like this:

```sh

MYSQL_HOST: mysql # DB host (container name or ip/url)
MYSQL_DB: airdrop
MYSQL_USER: root
MYSQL_PASSWORD: Pa55worD?! # set your DB password (same as in .env.sql.deploy)

APP_URL: 'http://your-custom-url.com' # set URL of your frontend application
ADMIN_WALLET: # your EVM wallet address

# Apillon configuration
# Create (free) account at https://apillon.io to and setup API key and NFT collection
APILLON_KEY: # Apillon api key
APILLON_SECRET: # Apillon api key secret
COLLECTION_UUID: # Apillon NFT collection UUID

# Your email server configuration
SMTP_HOST:
SMTP_PORT: '465'
SMTP_USERNAME:
SMTP_PASSWORD:
SMTP_EMAIL_FROM:
SMTP_NAME_FROM: 'NFT Airdrop'

# API configuration (you can just live it as it is or appropriate fix dockerfile and compose)
API_HOST: 0.0.0.0
API_PORT: 3000

# To Enable hCaptcha, register and get a secret. Remove or use blank if you don't need it.
CAPTCHA_SECRET:

#Number of hours user have to claim NFT, before they are removed from line and become un eligible to claim
CLAIM_EXPIRES_IN: # default 72
```

### .env.sql.deploy

For running a mysql docker image with [`docker-compose.yml`](/docker-compose.yml) you should create `.env.sql.deploy` file like this:

```sh
MYSQL_ROOT_PASSWORD: Pa55worD?! # set your DB password (same as in .env.deploy)
MYSQL_DATABASE: airdrop

```
## Deploying with docker

Build docker image with script [`./build-image.sh`](/build-image.sh) script or by running docker build command, for example:

```sh
docker build -t ps-signup-email-airdrop .
docker tag ps-signup-email-airdrop ps-signup-email-airdrop:latest
```

If you correctly setup .env files, you can run app in docker by running

```sh
docker compose up -d
```
4 changes: 0 additions & 4 deletions backend/build-image-beta.sh

This file was deleted.

9 changes: 5 additions & 4 deletions backend/build-image.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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
set -e

docker build -t ps-signup-email-airdrop .
docker tag ps-signup-email-airdrop ps-signup-email-airdrop:latest
# docker save -o ps-signup-email-airdrop.tar ps-signup-email-airdrop:latest
47 changes: 0 additions & 47 deletions backend/docker-compose.beta.yml

This file was deleted.

43 changes: 0 additions & 43 deletions backend/docker-compose.proxy.yml

This file was deleted.

37 changes: 20 additions & 17 deletions backend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
#####
# This is an example of docker compose file for Apillon pre-built solutions. You are encouraged to change it according to your needs.
#####

version: '3.8'

services:
airdrop_db:
image: mysql
container_name: airdrop_db

## Enviroment variables can be set in .env files or from build environment
## Here is how you can use .env file (note: should be separate for each container)
env_file:
- .env.sql.deploy

## If you want to read variables from build environment comment out above section and uncomment below
# environment:
# MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
# MYSQL_DATABASE: ${MYSQL_DATABASE}

ports:
- '3306:3306'
restart: always
volumes:
- mysql-data:/var/lib/mysql
networks:
- db

airdrop_app:
image: public.ecr.aws/i0e4n2k8/ment-airdrop:latest
image: ps-signup-email-airdrop:latest
container_name: airdrop_app
depends_on:
- airdrop_db

## Enviroment variables can be set in .env files or from build environment
## Here is how you can use .env file (note: should be separate for each container)
env_file:
- .env.deploy
restart: always
networks:
- web
- db

volumes:
mysql-data:

networks:
db:
web:
name: web
external: true
ports:
- '8080:3000'
restart: always
Loading

0 comments on commit 403d1a1

Please sign in to comment.