diff --git a/Dockerfile b/Dockerfile index 1f78a5d..18e3856 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,24 @@ # This is the base for our build step container -FROM node:10-alpine AS base +FROM node:12-alpine AS base # Install dependencies RUN apk add --no-cache git # Create and change to workdir WORKDIR /app -RUN git clone --branch 1.0.0 https://github.com/timeoff-management/application.git timeoff-management +RUN git clone --branch 1.1.1 https://github.com/timeoff-management/application.git timeoff-management WORKDIR /app/timeoff-management # Install dependencies RUN npm install mysql && npm install --production +# 20190118-chnage-type-value-for-api-token.js isn't compatible with mariadb. A better solution is used to replace it +# Issue comment: https://github.com/timeoff-management/timeoff-management-application/issues/329#issuecomment-488327844 +COPY scripts/20190118-chnage-type-value-for-api-token.js /app/timeoff-management/migrations/ + # This is our runtime container -FROM alpine:3.10 +FROM alpine:3.12 # Install npm RUN apk add --update nodejs npm @@ -24,11 +28,7 @@ WORKDIR /app/timeoff-management # Copy files from first stage COPY --from=base /app/timeoff-management/ /app/timeoff-management -# 20190118-chnage-type-value-for-api-token.js isn't compatible with mariadb. A fixed version is used to replace it -# Issue comment: https://github.com/timeoff-management/timeoff-management-application/issues/329#issuecomment-488327844 -COPY scripts/20190118-chnage-type-value-for-api-token.js /app/timeoff-management/migrations/ - ADD docker-entrypoint.sh /docker-entrypoint.sh EXPOSE 3000 -ENTRYPOINT ["sh", "/docker-entrypoint.sh"] +ENTRYPOINT ["sh", "/docker-entrypoint.sh"] \ No newline at end of file diff --git a/scripts/20190118-chnage-type-value-for-api-token.js b/scripts/20190118-chnage-type-value-for-api-token.js index 7638520..7249eb4 100644 --- a/scripts/20190118-chnage-type-value-for-api-token.js +++ b/scripts/20190118-chnage-type-value-for-api-token.js @@ -3,41 +3,22 @@ const models = require("../lib/model/db"); module.exports = { - up: function(queryInterface, Sequelize) { - return queryInterface.describeTable("Companies").then(attributes => { + up: function (queryInterface, Sequelize) { + return queryInterface.describeTable("Companies").then((attributes) => { if (attributes.integration_api_token.type === "UUID") { return 1; } - return ( - queryInterface - // Create Temp Compaies based on current model definitiom - .createTable("Companies_backup", models.Company.attributes) - .then(() => - queryInterface.sequelize.query("SET FOREIGN_KEY_CHECKS=0;") - ) - .then(() => - queryInterface.sequelize.query( - "INSERT INTO `Companies_backup` (`id`,`name`,`country`,`start_of_new_year`,`createdAt`,`updatedAt`,share_all_absences,ldap_auth_enabled,ldap_auth_config,`date_format`,`company_wide_message`,`mode`,`timezone`,`integration_api_token`,`integration_api_enabled`,`carry_over`) SELECT `id`,`name`,`country`,`start_of_new_year`,`createdAt`,`updatedAt`,share_all_absences,ldap_auth_enabled,ldap_auth_config,`date_format`,`company_wide_message`,`mode`,`timezone`,`integration_api_token`,`integration_api_enabled`,`carry_over` FROM `" + - models.Company.tableName + - "`" - ) - ) - .then(() => queryInterface.dropTable(models.Company.tableName)) - .then(() => - queryInterface.renameTable( - "Companies_backup", - models.Company.tableName - ) - ) - .then(() => queryInterface.sequelize.query("SET FOREIGN_KEY_CHECKS=1;")) - .then(() => queryInterface.addIndex(models.Company.tableName, ["id"])) + return queryInterface.changeColumn( + "Companies", + "integration_api_token", + models.Company.attributes.integration_api_token ); }); }, - down: function(queryInterface, Sequelize) { + down: function (queryInterface, Sequelize) { // No way back! return Promise.resolve(); - } + }, };