Add node-firestore-import-export to docker container.

Add data to import.
This commit is contained in:
2019-03-03 12:19:26 +07:00
parent 22ae5f09d2
commit 183bb16395
4 changed files with 151 additions and 1 deletions

View File

@@ -5,7 +5,9 @@ RUN npm config set cache /opt/pub/.npm
RUN apk upgrade --update \ RUN apk upgrade --update \
&& apk add --no-cache curl yarn git && apk add --no-cache curl yarn git
RUN yarn global add @vue/cli@3.4.1 RUN yarn global add \
@vue/cli@3.4.1 \
node-firestore-import-export
ARG WEB_USER_ID=33 ARG WEB_USER_ID=33
ARG WEB_USER_NAME=www-data ARG WEB_USER_NAME=www-data

View File

@@ -12,6 +12,21 @@ This is project based on [tproger course](https://tproger.ru/video/building-vuej
yarn install yarn install
``` ```
### Importing data to firestore
To achieve this goal we use [node-firestore-import-export library](https://www.npmjs.com/package/node-firestore-import-export).
1. Create `docker-compose.override.yml` and add this content to it
```
version: '3'
services:
app:
volumes:
- ~/path/to/firebase/credentials.json:/var/www/credentials.json
environment:
- GOOGLE_APPLICATION_CREDENTIALS=/var/www/cred.json
```
1. Run `docker-compose exec app firestore-import --yes --backupFile /var/www/vue/data/back-up.json`
### Compiles and hot-reloads for development ### Compiles and hot-reloads for development
``` ```
yarn run serve yarn run serve

131
data/back-up.json Normal file
View File

@@ -0,0 +1,131 @@
{
"__collections__": {
"articles": {
"hp1": {
"description": "Первая глава первой книги о Гарри Поттере",
"level": [
"B2",
"C1"
],
"imageUrl": "https://firebasestorage.googleapis.com/v0/b/ich-lerne-deutsch-27b7b.appspot.com/o/hp.jpg?alt=media&token=7f11f093-aef3-46cc-b443-823515399913",
"youtubePlaylistId": "asdadsadad",
"title": "Harry Potter und Stein der Weisen - 1",
"parts": [
{
"title": "kapitel 1",
"youtubeId": "bsdasdad1",
"id": "k1"
},
{
"youtubeId": "bsdasdad2",
"id": "k2",
"title": "kapitel 2"
},
{
"title": "kapitel 3",
"youtubeId": "bsdasdad3",
"id": "k3"
}
],
"__collections__": {}
},
"hp2": {
"level": [
"B1",
"B2"
],
"imageUrl": "https://firebasestorage.googleapis.com/v0/b/ich-lerne-deutsch-27b7b.appspot.com/o/hp.jpg?alt=media&token=7f11f093-aef3-46cc-b443-823515399913",
"youtubePlaylistId": "asdadsadad234234",
"title": "Harry Potter und Stein der Weisen - 2",
"parts": [
{
"youtubeId": "bsdasdad1",
"id": "k1",
"title": "kapitel 1"
}
],
"description": "Вторая глава первой книги о Гарри Поттере",
"__collections__": {}
},
"hp3": {
"level": ["A2"],
"imageUrl": "https://firebasestorage.googleapis.com/v0/b/ich-lerne-deutsch-27b7b.appspot.com/o/hp.jpg?alt=media&token=7f11f093-aef3-46cc-b443-823515399913",
"youtubePlaylistId": "asdadsada435346",
"title": "Harry Potter und Stein der Weisen - 3",
"parts": [
{
"id": "bsdasdad123",
"title": "kapitel 1",
"youtubeId": "bsdasdad1"
},
{
"id": "bsdasdad124",
"title": "kapitel 2",
"youtubeId": "bsdasdad2"
},
{
"id": "bsdasdad125",
"title": "kapitel 3",
"youtubeId": "bsdasdad3"
}
],
"description": "Третья глава первой книги о Гарри Поттере",
"__collections__": {}
}
},
"articleParts": {
"hp1k1": {
"content": [
{
"sentences": [
{
"origText": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"transText": "Бла"
},
{
"origText": "Praesent ligula odio, interdum pretium ligula eu, vehicula consequat nulla. Etiam a massa iaculis, aliquet metus sit amet, varius odio",
"transText": "Бла2"
},
{
"transText": "Бла3",
"origText": "Suspendisse quis mi eget nisl accumsan molestie in vel lorem. Duis ipsum massa, pharetra nec arcu sed, mattis ultricies neque."
},
{
"origText": "Sed lacinia sed justo sit amet porttitor. Etiam nec nisi nibh. Donec dolor lacus, volutpat in pellentesque vel, accumsan ac nisi.",
"transText": "Бла4"
}
]
},
{
"sentences": [
{
"transText": у1",
"origText": "Etiam magna dui, pulvinar quis finibus malesuada, vulputate non sem. In hendrerit dui sem, a cursus ipsum interdum non."
},
{
"origText": "Curabitur porta sagittis lacus.",
"transText": у2"
}
]
}
],
"articleId": "hp1",
"partTitle": "kapitel 1",
"words": [
{
"origWord": "Hallo",
"transWord": "Привет"
},
{
"transWord": "Привет",
"origWord": "Hallo1"
}
],
"articlePartId": "k1",
"youtubeId": "hHW1oY26kxQ",
"articleTitle": "Harry Potter und Stein der Weisen - 1",
"__collections__": {}
}
}
}
}

View File

@@ -7,6 +7,8 @@ services:
args: args:
WEB_USER_ID: 33 WEB_USER_ID: 33
WEB_USER_NAME: www-data WEB_USER_NAME: www-data
environment:
- GOOGLE_APPLICATION_CREDENTIALS=
working_dir: /var/www/vue working_dir: /var/www/vue
expose: expose:
- 8000 - 8000