I have an issue where the size of the zipped lambdas are much larger on the cdci (GitLab CE 11.8.0) than when running the package script locally.
The lambdas are written in typescript and I use serverless-webpack to decrease the size as much as I can.
I have not written the code so I don’t know why they are so large
but still I think there should not really be that big of a difference between local and cdci packaging?
Am I missing something?
Here is the build log: https://pastebin.com/pcG7QaAg
Size when running serverless package
locally:
getReport.zip: 28.6 MB
push.zip: 25.8 MB
alerts.zip: 25.8 MB
reporting: 5 MB
user.zip: 2.3 MB
imageupload.zip: 90 KB
Size when running serverless deploy
on cdci:
getReport.zip: 168.76 MB
push.zip: 92.91 MB
alerts.zip: 92.91 MB
reporting: 4.7 MB
user.zip: 2.08 MB
imageupload.zip: 55.68 KB
serverless.yml:
plugins:
- serverless-dotenv-plugin
- serverless-offline
- serverless-plugin-aws-alerts
- serverless-plugin-info-json
- serverless-webpack
package:
individually: true
exclude:
- node_modules/aws-sdk/**
provider:
name: aws
region: eu-west-1
runtime: nodejs10.x
memorySize: 512
timeout: 30
versionFunctions: false
stage: ${opt:stage, 'dev'}
apiGateway:
shouldStartNameWithService: true
custom:
webpack:
webpackConfig: ./webpack.config.js
includeModules: true
.gitlab-ci.yml:
.deploy_to_aws:
image: node:latest
script:
- npm i -g serverless
- npm ci
- serverless config credentials --provider aws --key $AWS_ACCESS_KEY_ID --secret $AWS_SECRET_ACCESS_KEY
- serverless deploy --verbose --stage $STAGE --region $AWS_DEFAULT_REGION
webpack.config.js
const path = require("path")
const slsw = require("serverless-webpack")
const nodeExternals = require("webpack-node-externals")
module.exports = {
context: __dirname,
mode: slsw.lib.webpack.isLocal ? "development" : "production",
entry: slsw.lib.entries,
resolve: {
extensions: [".ts"],
symlinks: false,
cacheWithContext: false,
},
output: {
libraryTarget: "commonjs",
path: path.join(__dirname, ".webpack"),
filename: "[name].js",
},
target: "node",
externals: [nodeExternals()],
module: {
rules: [
{
test: /\.(ts)$/,
loader: "ts-loader",
exclude: [
[
path.resolve(__dirname, "node_modules"),
path.resolve(__dirname, ".serverless"),
path.resolve(__dirname, ".webpack"),
],
],
options: {
transpileOnly: true,
experimentalWatchApi: true,
},
},
],
},
}