Skip to content

[refactor] Read Env in running time #30

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

Merged
merged 13 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ dist-ssr
*.sln
*.sw?
.env
*.ps1
12 changes: 2 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,12 @@ ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

FROM base AS prod

WORKDIR /app
COPY . .

RUN pnpm install --frozen-lockfile
RUN pnpm run build

FROM nginx:stable-alpine

COPY nginx.conf /etc/nginx/conf.d/default.conf

COPY --from=prod /app/dist/ /app
RUN pnpm install -D express

EXPOSE 80

CMD [ "nginx" ]
CMD [ "cd /app && pnpm run build && node server.js" ]
8 changes: 8 additions & 0 deletions farm.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ export default defineConfig({
alias: {
"~/": path.join(process.cwd(), "src"),
}
},
define: {
SD_BACKEND_URL: process.env.SD_BACKEND_URL,
SD_CLIENT_ID: process.env.SD_CLIENT_ID,
SD_AUTHORITY_URL: process.env.SD_AUTHORITY_URL,
SD_REDIRECT_URL: process.env.SD_REDIRECT_URL,
SD_LOGOUT_REDIRECT_URL: process.env.SD_LOGOUT_REDIRECT_URL,
SD_AUTH_SECRET: process.env.SD_AUTH_SECRET,
}
},
envPrefix: "SD_",
Expand Down
18 changes: 0 additions & 18 deletions nginx.conf

This file was deleted.

15 changes: 15 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import express, { static } from "express";
import { join } from "path";

const app = express();
const port = 80;

app.use(static(join(__dirname, "dist")));

app.get("*", (req, res) => {
res.sendFile(join(__dirname, "dist", "index.html"));
});

app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});