Merge pull request #2215 from balena-os/fix-service-network

Revert "Do not expose ports from image if service network mode"
This commit is contained in:
flowzone-app[bot] 2023-10-16 16:58:27 +00:00 committed by GitHub
commit 8981ee58cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 32 deletions

View File

@ -346,9 +346,7 @@ export class Service {
'Config.ExposedPorts',
{},
);
if (!serviceNetworkMode) {
expose = expose.concat(_.keys(imageExposedPorts));
}
// Also add any exposed ports which are implied from the portMaps
const exposedFromPortMappings = _.flatMap(portMaps, (port) =>
port.toExposedPortArray(),

View File

@ -1082,35 +1082,6 @@ describe('compose/service: unit tests', () => {
return expect(dockerSvc.isEqualConfig(composeSvc, { test: 'qwerty' })).to
.be.false;
});
it('should omit exposing ports from the source image', async () => {
const s = await Service.fromComposeObject(
{
appId: '1234',
serviceName: 'foo',
releaseId: 2,
serviceId: 3,
imageId: 4,
composition: {
network_mode: 'service: test',
expose: ['433/tcp'],
},
},
{
appName: 'test',
imageInfo: {
Config: {
ExposedPorts: {
'8080/tcp': {},
},
},
},
} as any,
);
// Only explicitely exposed ports are set if network_mode: service is used
expect(s.config.expose).to.deep.equal(['433/tcp']);
});
});
describe('Security options', () => {