Skip to content

Commit

Permalink
public: Rework Containerfile for Nuxt
Browse files Browse the repository at this point in the history
  • Loading branch information
somnisomni committed Jun 21, 2024
1 parent 378b8c7 commit a64f497
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 14 deletions.
2 changes: 1 addition & 1 deletion MyBoothManager.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@
"eslint.lintTask.enable": true,
"eslint.run": "onType",
"eslint.packageManager": "pnpm",
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "./node_modules/typescript/lib"
}
}
13 changes: 9 additions & 4 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,25 @@ services:
- "31112:31112"
depends_on:
- backend
restart: unless-stopped
network_mode: host # Should ditch host network mode and use bridge mode instead
# But I have to find a way to get rid of errors of CNI network automatically created by podman-compose

public:
build:
context: .
dockerfile: ./projects/Public/Containerfile
args:
GIT_HASH: ${GIT_COMMIT_HASH}
API_SERVER_URL: "http://localhost:31111"
BASE_PATH: "/"
environment:
NITRO_PORT: 31113
GIT_HASH: ${GIT_COMMIT_HASH}
NUXT_API_SERVER_URL: "http://localhost:31111"
NUXT_API_SERVER_UPLOADS_PATH: "uploads"
NUXT_APP_BASE_PATH: "/"
ports:
- "31113:31113"
depends_on:
- backend
restart: unless-stopped
network_mode: host

backend:
Expand All @@ -52,6 +56,7 @@ services:
COOKIE_SECRET: in_myboothmanager_mos
FRONTEND_ADMIN_URL: "http://localhost:31112"
FRONTEND_PUBLIC_URL: "http://localhost:31113"
restart: unless-stopped
network_mode: host

volumes:
Expand Down
41 changes: 41 additions & 0 deletions projects/Public/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
### BASE ###
FROM node:lts-alpine as base

### BUILD STAGE ###
FROM base as build
RUN corepack enable pnpm

# Build arguments
ARG GIT_HASH
ENV GIT_HASH=${GIT_HASH}

# Copy files
WORKDIR /build
COPY package.json .
COPY pnpm-*.yaml .
COPY packages/ packages/
COPY projects/Public projects/Public

# Build
# RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
# pnpm install --frozen-lockfile
RUN pnpm install --frozen-lockfile
RUN pnpm common:build && pnpm public build

# Deploy
RUN pnpm deploy --filter @myboothmanager/public --prod /prod/public


### PRODUCTION STAGE ###
FROM base as production
RUN corepack enable pnpm

# Copy files
WORKDIR /app
COPY --from=build /prod/public .

# Expose port
EXPOSE 31113

# Start server
ENTRYPOINT ["/bin/sh", "-c", "pnpm start:prod"]
17 changes: 8 additions & 9 deletions projects/Public/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ if(!commitHash) {
}
/* === */

/* === Startup Debug Logging === */
console.debug();
console.debug(" *** PUBLIC *** ");
console.debug("Starting Nuxt.js for " + process.env.NODE_ENV + " environment");
console.debug(` - package.json app version: ${packageJson.version}`);
console.debug(` - Git hash: ${commitHash}`);
console.debug();
/* === */

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
ssr: true,
Expand Down Expand Up @@ -54,6 +45,13 @@ export default defineNuxtConfig({
transformAssetUrls,
},
},
esbuild: {
tsconfigRaw: {
compilerOptions: {
experimentalDecorators: true,
},
},
},
},
css: [
"~/assets/styles/styles.scss",
Expand Down Expand Up @@ -94,4 +92,5 @@ export default defineNuxtConfig({
devtools: {
enabled: true,
},
telemetry: false,
});

0 comments on commit a64f497

Please sign in to comment.