Skip to content

Commit

Permalink
Use separate node build
Browse files Browse the repository at this point in the history
  • Loading branch information
aeifn committed Dec 27, 2023
1 parent 5ba491c commit 8038c25
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 22 deletions.
9 changes: 1 addition & 8 deletions .docker/backend.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,10 @@ RUN apt-get update && apt-get install -y \
&& rm -rf /var/lib/apt/lists/*
COPY ./.docker/imagick-policy.xml /etc/ImageMagick-6/policy.xml

FROM node:${NODE_TAG} AS builder
WORKDIR /build
COPY package.json .
RUN npm install
COPY . .
RUN npm run build

FROM base
WORKDIR /code
ENV NODE_ENV production
COPY --from=builder /appBuild/ .
COPY ./appBuild/ .
RUN npm install --production
RUN mkdir /store && chown node:node /store
RUN mkdir /sitemap && chown node:node /sitemap
Expand Down
10 changes: 1 addition & 9 deletions .docker/frontend.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
ARG NODE_TAG=16.19.0

FROM node:${NODE_TAG} AS builder
WORKDIR /build
COPY package.json .
RUN npm install
COPY . .
RUN --mount=type=secret,id=SENTRY_AUTH_TOKEN \
SENTRY_AUTH_TOKEN=$(cat /run/secrets/SENTRY_AUTH_TOKEN) npm run build

FROM nginx:1.21.3
COPY --from=builder /appBuild/public/ /usr/share/nginx/html/
COPY ./appBuild/public/ /usr/share/nginx/html/
19 changes: 16 additions & 3 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,24 @@ jobs:
if: github.repository_owner == 'pastvu'
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16.19.0

- name: Build
run: |
npm ci
npm run build
- name: Sentry
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
run: |
npm run sentry:sourcemaps
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
Expand Down Expand Up @@ -58,8 +73,6 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
secrets: |
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
file: ./.docker/frontend.Dockerfile
tags: ${{ steps.docker_meta_frontend.outputs.tags }}
labels: ${{ steps.docker_meta_frontend.outputs.labels }}
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ public/style/**/*.css
babel/output*.js
# Sentry Config File
.sentryclirc

appBuild
app*.zip
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": false,
"singleQuote": true
}
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function (grunt) {
const path = require('path');
const Utils = require('./commons/Utils');
const env = grunt.option('env') || 'production'; // Например, --env testing
const upperDir = path.normalize(path.resolve('../') + '/');
const upperDir = path.normalize(path.resolve('./') + '/');
const targetDir = path.normalize(upperDir + 'appBuild/');
const babelConfig = require('./babel/server.config');
const hash = Utils.randomString(5);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"lint": "./node_modules/.bin/eslint .",
"lintfix": "./node_modules/.bin/eslint . --fix",
"jest": "jest --runInBand",
"build": "grunt && npm run sentry:sourcemaps",
"build": "grunt",
"test": "grunt test",
"migrate": "npm run migrate:up",
"migrate:create": "migrate-mongo create -f config/migrate-mongo.js -- ",
Expand Down

0 comments on commit 8038c25

Please sign in to comment.