Skip to content

Commit

Permalink
specify port in env
Browse files Browse the repository at this point in the history
  • Loading branch information
alcaprar committed Jun 1, 2024
1 parent 98cf420 commit 9f630bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ services:
dockerfile: Dockerfile
# image: ghcr.io/alcaprar/pagescms:latest
ports:
- "3000:3000"
- "3001:3001"
environment:
- SERVER_PORT=3001
- GITHUB_CLIENT_ID=Ov23lizf1MrBLbVjp005
- GITHUB_CLIENT_SECRET=51795afaff57e22d4c7f3a0e35a4fbbcca597338
2 changes: 2 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ if [ -z "${GITHUB_CLIENT_SECRET-}" ]; then
fi

BASE_URL="${BASE_URL:-http://localhost:3000}"
SERVER_PORT="${SERVER_PORT:-3000}"

CONFIG_FILE=".env"
touch $CONFIG_FILE
echo "BASE_URL = \"${BASE_URL}\"" > $CONFIG_FILE
echo "SERVER_PORT = \"${SERVER_PORT}\"" >> $CONFIG_FILE
echo "GITHUB_CLIENT_ID = \"${GITHUB_CLIENT_ID}\"" >> $CONFIG_FILE
echo "GITHUB_CLIENT_SECRET = \"${GITHUB_CLIENT_SECRET}\"" >> $CONFIG_FILE

Expand Down
6 changes: 4 additions & 2 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const __dirname = import.meta.dirname;

const app = express();

const SERVER_PORT = config.SERVER_PORT || 3000;

app.get('/', function (req, res) {
res.sendFile(path.join(__dirname, '../dist/index.html'));
});
Expand Down Expand Up @@ -89,6 +91,6 @@ app.get("/auth/revoke", async (request, response) => {
return response.status(200).send("Token revoked");
})

app.listen(3000, () => {
console.log("Listen on the port 3000...");
app.listen(SERVER_PORT, () => {
console.log(`Listen on the port ${SERVER_PORT}...`);
});

0 comments on commit 9f630bd

Please sign in to comment.