Skip to content

Commit bb9c3c9

Browse files
committed
FIX Added PORT forwarding depending on environment var
This environment vas is just PORT and has been added to the Dev Container config file
1 parent 8da7b46 commit bb9c3c9

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

.devcontainer/devcontainer.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
}
1212
},
1313
"runArgs": ["--hostname","${localEnv:OAUTH_ASTRO_CONTAINER_HOSTNAME:astro.dev}"],
14+
"containerEnv": { "PORT": "8080" },
1415
"customizations": {
1516
"vscode": {
1617
"extensions": [
@@ -21,13 +22,20 @@
2122
"donjayamanne.githistory"
2223
]
2324
}
24-
}
25+
},
2526

2627
// Features to add to the dev container. More info: https://containers.dev/features.
2728
// "features": {},
2829

2930
// Use 'forwardPorts' to make a list of ports inside the container available locally.
30-
// "forwardPorts": [],
31+
"forwardPorts": [8080],
32+
"portsAttributes": {
33+
"8080": {
34+
"label": "FrontendToBackend",
35+
"requireLocalPort": true,
36+
"elevateIfNeeded": true
37+
}
38+
}
3139

3240
// Use 'postCreateCommand' to run commands after the container is created.
3341
// "postCreateCommand": "yarn install",

astro.config.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import tailwind from '@astrojs/tailwind';
66

77

88
const HOSTNAME = process.env.HOSTNAME
9+
const PORT = parseInt(process.env.PORT)
910

1011
const options = {
1112
key: fs.readFileSync("./private/server.key"),
@@ -15,7 +16,8 @@ const options = {
1516
// https://astro.build/config
1617
export default defineConfig({
1718
output: 'server',
18-
vite: { server: {https: options} },
19+
vite: { server: {https: options, port: PORT }},
20+
server: { port: PORT },
1921
adapter: node({mode:'standalone'}),
2022
site: `https://${HOSTNAME}}`,
2123
integrations: [tailwind()],

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
"type": "module",
44
"version": "0.0.1",
55
"scripts": {
6-
"dev": "astro dev",
7-
"start": "astro dev",
6+
"dev": "astro dev --host",
7+
"start": "astro dev --host",
88
"build": "astro check && astro build",
99
"preview": "astro preview",
1010
"astro": "astro",
11-
"ssr": "SERVER_KEY_PATH=./private/server.key SERVER_CERT_PATH=./private/server.crt HOST=127.0.0.1 PORT=4321 node ./dist/server/entry.mjs"
11+
"ssr": "SERVER_KEY_PATH=./private/server.key SERVER_CERT_PATH=./private/server.crt HOST=127.0.0.1 PORT=$PORT node ./dist/server/entry.mjs"
1212
},
1313
"dependencies": {
1414
"@astrojs/check": "^0.9.3",

0 commit comments

Comments
 (0)