Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve issue of error when connecting to mssql with docker image or exe #2370

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Builder
#
FROM node:14-alpine3.17 AS builder
FROM node:20-alpine3.17 as builder

WORKDIR /opt/azurite

Expand All @@ -11,16 +11,14 @@ COPY *.json LICENSE NOTICE.txt ./
# Copy the source code and build the app
COPY src ./src
COPY tests ./tests
RUN npm config set unsafe-perm=true && \
npm ci
RUN npm ci --unsafe-perm
RUN npm run build && \
npm install -g --loglevel verbose
npm install -g --unsafe-perm --loglevel verbose


#
# Production image
#
FROM node:14-alpine3.17
FROM node:20-alpine3.17

ENV NODE_ENV=production

Expand All @@ -33,8 +31,11 @@ COPY package*.json LICENSE NOTICE.txt ./

COPY --from=builder /opt/azurite/dist/ dist/

RUN npm config set unsafe-perm=true && \
npm install -g --loglevel verbose
RUN npm pkg set scripts.prepare="echo no-prepare"

RUN npm ci --unsafe-perm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to additionally add npm ci?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After Node16, the install -g only copies content under local folder to global folder, it didn't install anything. npm ci is to install dependencies into local folder first


RUN npm install -g --unsafe-perm --loglevel verbose

# Blob Storage Port
EXPOSE 10000
Expand Down
14 changes: 7 additions & 7 deletions scripts/buildExe.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ const pkgFetch = require('pkg-fetch');
build();

async function build() {
const pkgTarget = 'node14-win-x64';
const pkgTarget = 'node20-win-x64';
const cacheExe = await downloadCache(pkgTarget);
await rcedit(cacheExe, {
"version-string": {
"CompanyName": "Microsoft",
"ProductName": "Azurite",
"FileDescription": "Azurite",
"CompanyName": "Microsoft",
"ProductName": "Azurite",
"FileDescription": "Azurite",
"ProductVersion": pjson.version,
"OriginalFilename": "",
"InternalName": "node",
Expand All @@ -27,7 +27,7 @@ async function build() {
// file-version is kept as the node version used by the .exe for debugging purposes
"icon": path.resolve('.\\icon.ico')
});

// rename the cache file to skip hash check by pkg-fetch since hash check reverts our change of properties
const newName = cacheExe.replace("fetched", "built");

Expand All @@ -38,14 +38,14 @@ async function build() {
}

await asyncRename(cacheExe, newName);

const outputExe = path.resolve('.\\release\\azurite.exe');
await pkg.exec([path.resolve('.'), ...['--target', pkgTarget], ...['--output', outputExe], ...['-C', 'Brotli']]);
}

async function downloadCache(pkgTarget) {
const [nodeRange, platform, arch] = pkgTarget.split('-');

await pkgFetch.need({ nodeRange, platform, arch });
const cacheExe = glob.sync(process.env.PKG_CACHE_PATH + "\\**\\fetched*");
if (cacheExe.length < 1) {
Expand Down
Loading