db; docker updates

This commit is contained in:
Alexey 2020-01-31 20:03:09 +03:00
parent 5a51b659b5
commit 0de5c68d56
10 changed files with 51 additions and 13 deletions

View File

@ -4,10 +4,13 @@ AWS_S3_BUCKET=
DISABLE_S3=false
MYSQL_USER=root
MYSQL_PASSWORD=secret
MYSQL_PASSWORD=webmailpasswd
MYSQL_DATABASE=phase2
TWITTER_CONSUMER_KEY=
TWITTER_CONSUMER_SECRET=
TWITTER_CALLBACK_URL=http://localhost:3000/api/twitter_callback
SESSION_SECRET=
NUXT_HOST=0.0.0.0
NUXT_PORT=3000

View File

@ -1,10 +1,15 @@
FROM tornadocash/phase2-bn254 as bin
FROM node:11
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install && npm cache clean --force
COPY package.json yarn.lock ./
RUN yarn install && yarn cache clean --force
COPY . .
COPY --from=bin /usr/bin/phase2_verify_contribution /app/bin/
EXPOSE 3000
HEALTHCHECK CMD curl -f http://localhost:3000/
CMD ["npm", "run", "start"]
RUN yarn build
CMD ["yarn", "start"]

View File

@ -4,13 +4,13 @@ services:
build: .
restart: always
environment:
VIRTUAL_HOST: trustedaf.poma.in
LETSENCRYPT_HOST: trustedaf.poma.in
VIRTUAL_HOST: ceremony.tornado.cash
LETSENCRYPT_HOST: ceremony.tornado.cash
nginx_client_max_body_size: 50m
MYSQL_HOST: mysql
env_file: .env
volumes:
- /data/powers/verify_contribution:/app/verify_contribution
depends_on:
- mysql
mysql:
image: mysql:5.7

View File

@ -99,7 +99,12 @@ module.exports = {
** Axios module configuration
** See https://axios.nuxtjs.org/options
*/
axios: {},
axios: {
baseURL:
process.env.NODE_ENV === 'production'
? 'http://ceremony.tornado.cash/'
: `http://localhost:3000/`
},
/*
** Build configuration
*/

13
seed.sql Normal file
View File

@ -0,0 +1,13 @@
create table contributions
(
id int auto_increment,
token varchar(64) not null,
name varchar(255) null,
company varchar(255) null,
hash varchar(130) null,
constraint contributions_pk
primary key (id)
);
create unique index contributions_token_uindex on contributions (token);

View File

@ -29,7 +29,7 @@ async function uploadToS3({ filename }) {
async function verifyResponse({ filename }) {
console.log('Running verifier')
const { stdout, stderr } = await exec(
`../bin/verify_contribution circuit.json current.params /tmp/tornado/${filename}`,
`../bin/phase2_verify_contribution circuit.json current.params /tmp/tornado/${filename}`,
{
cwd: './server/snark_files/',
env: { RUST_BACKTRACE: 1 }

View File

@ -1,4 +1,5 @@
const crypto = require('crypto')
const fs = require('fs')
const db = require('./db.js')
let sql
@ -33,6 +34,18 @@ Contributions.getContributions = async function() {
async function main() {
;({ sql } = await db())
const [rows] = await sql.query("show tables like 'contributions'")
if (rows.length === 0) {
console.log('Database appears to be empty, creating tables')
const sqlFile = await fs.readFileSync('seed.sql')
for (const s of sqlFile.toString().split(';')) {
if (s.trim().length > 0) {
await sql.query(s)
}
}
}
const contribitionIndex = await Contributions.currentContributionIndex()
console.log('Next contribution index is', contribitionIndex)
}

View File

@ -16,7 +16,6 @@ const mysql = require('mysql2/promise')
// currentContributionIndex = (rows[0].max || 0) + 1
// console.log('Current contribution index:', currentContributionIndex)
module.exports = async function() {
this.sql = await mysql.createPool({
host: process.env.MYSQL_HOST || 'localhost',

Binary file not shown.