diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..588e887 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +FROM node:22-alpine AS build-frontend + +WORKDIR /app + +COPY web/package*.json ./ + +RUN npm install + +RUN npm install -g @angular/cli + +COPY web . + +RUN ng build --configuration=production + +RUN ls -R dist + +FROM golang:1.24-alpine AS build-backend + +RUN apk add --no-cache --update gcc g++ + +WORKDIR /usr/src/app + +COPY go.mod go.mod +COPY go.sum go.sum + +RUN go mod download + +COPY . . +ENV CGO_ENABLED=1 +COPY --from=build-frontend app/dist/frontend/browser /web/app/dist/frontend/browser + +RUN go build -o=ng-blog cmd/main.go + +FROM alpine:latest + +WORKDIR / + +COPY --from=build-backend /usr/src/app/ng-blog /ng-blog + +EXPOSE 8080 + +ENTRYPOINT ["/ng-blog", "serve"] + diff --git a/backend b/backend index 84362d4..163e641 100755 Binary files a/backend and b/backend differ diff --git a/web/angular.json b/web/angular.json index 0866799..cc91bb8 100644 --- a/web/angular.json +++ b/web/angular.json @@ -16,9 +16,7 @@ "outputPath": "dist/frontend", "index": "src/index.html", "browser": "src/main.ts", - "polyfills": [ - "zone.js" - ], + "polyfills": ["zone.js"], "tsConfig": "tsconfig.app.json", "assets": [ { @@ -26,9 +24,7 @@ "input": "public" } ], - "styles": [ - "src/styles.css" - ], + "styles": ["src/styles.css"], "scripts": [] }, "configurations": { @@ -45,6 +41,12 @@ "maximumError": "8kB" } ], + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.production.ts" + } + ], "outputHashing": "all" }, "development": { @@ -73,10 +75,7 @@ "test": { "builder": "@angular-devkit/build-angular:karma", "options": { - "polyfills": [ - "zone.js", - "zone.js/testing" - ], + "polyfills": ["zone.js", "zone.js/testing"], "tsConfig": "tsconfig.spec.json", "assets": [ { @@ -84,9 +83,7 @@ "input": "public" } ], - "styles": [ - "src/styles.css" - ], + "styles": ["src/styles.css"], "scripts": [] } } diff --git a/web/src/environments/environment.production.ts b/web/src/environments/environment.production.ts new file mode 100644 index 0000000..2ab9d38 --- /dev/null +++ b/web/src/environments/environment.production.ts @@ -0,0 +1,4 @@ +export const environment = { + production: true, + apiRoot: '/api', +};