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 DISABLE_S3=false
MYSQL_USER=root MYSQL_USER=root
MYSQL_PASSWORD=secret MYSQL_PASSWORD=webmailpasswd
MYSQL_DATABASE=phase2 MYSQL_DATABASE=phase2
TWITTER_CONSUMER_KEY= TWITTER_CONSUMER_KEY=
TWITTER_CONSUMER_SECRET= TWITTER_CONSUMER_SECRET=
TWITTER_CALLBACK_URL=http://localhost:3000/api/twitter_callback TWITTER_CALLBACK_URL=http://localhost:3000/api/twitter_callback
SESSION_SECRET= 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 FROM node:11
WORKDIR /app WORKDIR /app
COPY package.json package-lock.json ./ COPY package.json yarn.lock ./
RUN npm install && npm cache clean --force RUN yarn install && yarn cache clean --force
COPY . . COPY . .
COPY --from=bin /usr/bin/phase2_verify_contribution /app/bin/
EXPOSE 3000 EXPOSE 3000
HEALTHCHECK CMD curl -f http://localhost: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: . build: .
restart: always restart: always
environment: environment:
VIRTUAL_HOST: trustedaf.poma.in VIRTUAL_HOST: ceremony.tornado.cash
LETSENCRYPT_HOST: trustedaf.poma.in LETSENCRYPT_HOST: ceremony.tornado.cash
nginx_client_max_body_size: 50m nginx_client_max_body_size: 50m
MYSQL_HOST: mysql MYSQL_HOST: mysql
env_file: .env env_file: .env
volumes: depends_on:
- /data/powers/verify_contribution:/app/verify_contribution - mysql
mysql: mysql:
image: mysql:5.7 image: mysql:5.7
@ -27,4 +27,4 @@ volumes:
networks: networks:
default: default:
external: external:
name: frontend_default name: frontend_default

View File

@ -99,7 +99,12 @@ module.exports = {
** Axios module configuration ** Axios module configuration
** See https://axios.nuxtjs.org/options ** See https://axios.nuxtjs.org/options
*/ */
axios: {}, axios: {
baseURL:
process.env.NODE_ENV === 'production'
? 'http://ceremony.tornado.cash/'
: `http://localhost:3000/`
},
/* /*
** Build configuration ** 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 }) { async function verifyResponse({ filename }) {
console.log('Running verifier') console.log('Running verifier')
const { stdout, stderr } = await exec( 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/', cwd: './server/snark_files/',
env: { RUST_BACKTRACE: 1 } env: { RUST_BACKTRACE: 1 }

View File

@ -1,4 +1,5 @@
const crypto = require('crypto') const crypto = require('crypto')
const fs = require('fs')
const db = require('./db.js') const db = require('./db.js')
let sql let sql
@ -33,6 +34,18 @@ Contributions.getContributions = async function() {
async function main() { async function main() {
;({ sql } = await db()) ;({ 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() const contribitionIndex = await Contributions.currentContributionIndex()
console.log('Next contribution index is', contribitionIndex) console.log('Next contribution index is', contribitionIndex)
} }

View File

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

Binary file not shown.