Skip to content
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

GitHub actions #1

Merged
merged 13 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
26 changes: 26 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
**/*.log
**/*.md
**/*.dist
**/*.cache
**/._*
**/.dockerignore
**/.DS_Store
**/.git/
**/.gitattributes
**/.gitignore
**/.gitmodules
**/compose.*.yaml
**/compose.*.yml
**/compose.yaml
**/compose.yml
**/docker-compose.*.yaml
**/docker-compose.*.yml
**/docker-compose.yaml
**/docker-compose.yml
**/Dockerfile
**/Thumbs.db
.github/
.editorconfig
Rocket.toml
.git/
.idea/
52 changes: 52 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build
env:
IMAGE_TAG_CLIENT: ghcr.io/werify-eu/werify_client/werify_client
IMAGE_VERSION: ${{ github.ref == 'refs/heads/main' && 'latest' || 'staging' }}
on:
push:
branches:
- master
- develop
- github_actions

jobs:
build_werify_client:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'yarn'

- name: Docker Buildx Install
uses: docker/setup-buildx-action@v3

- name: Yarn install app
run: yarn install

- name: Yarn build app
run: yarn run build

- name: Docker build image
uses: docker/build-push-action@v5
with:
context: .
target: production
push: true
tags: ${{env.IMAGE_TAG_CLIENT}}:${{env.IMAGE_VERSION}}
cache-from: type=gha
cache-to: type=gha,mode=max
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ Desktop.ini

# npm package lock file
package-lock.json
yarn.lock

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
Expand Down Expand Up @@ -94,3 +93,6 @@ dist

# Serverless directories
.serverless

# Compose override for development
docker-compose.override.yml
28 changes: 22 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
FROM node:latest
FROM node:20 as base

LABEL com.centurylinklabs.watchtower.enable="true"

WORKDIR /usr/src/app

COPY package*.json ./
EXPOSE 3002

RUN npm install

COPY . .

EXPOSE 3002
FROM base as development

RUN yarn add nodemon

CMD ["npx", "nodemon", "src/server.js"]



FROM base as production

COPY node_modules ./node_modules

COPY dist ./dist/

COPY src/public ./dist/public

COPY src/views ./dist/views

CMD ["node", "src/server.js"]
CMD ["node", "dist/server.js"]
9 changes: 3 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
version: '3'
services:
web:
build: .
build:
context: .
target: production
ports:
- "3002:3002"
environment:
- MONGODB_URI=mongodb://mongo:27017/client_werifydb
depends_on:
- mongo
mongo:
image: mongo
ports:
- "27017:27017"
volumes:
- ./mongod.conf:/etc/mongod.conf
- ./mongod.conf.orig:/etc/mongod.conf.orig
restart: always
30 changes: 0 additions & 30 deletions mongod.conf.orig

This file was deleted.

22 changes: 14 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
{
"name": "client",
"version": "1.0.0",
"main": "index.js",
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack --mode production",
"start": "node src/server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"@babel/core": "^7.24.5",
"@babel/preset-env": "^7.24.5",
"babel-loader": "^9.1.3",
"body-parser": "^1.20.2",
"crypto": "^1.0.1",
"buffer": "^6.0.3",
"dotenv": "^16.3.1",
"ejs": "^3.1.9",
"express": "^4.18.2",
"express-session": "^1.17.3",
"jsonwebtoken": "^9.0.2",
"mongoose": "^8.0.2",
"node-jose": "^2.2.0"
"stream-browserify": "^3.0.0",
"webpack": "^5.91.0"
},
"devDependencies": {
"webpack-cli": "^5.1.4",
"webpack-node-externals": "^3.0.0"
}
}
2 changes: 1 addition & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ app.use('*', (req, res) => {
res.redirect('/client/home#');
});

module.exports = app;
module.exports = app;
38 changes: 38 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const path = require('path');
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');

module.exports = {
target: 'node', // Importante para indicar que el bundle es para Node.js
entry: './src/server.js', // Tu archivo de entrada del servidor
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'server.js'
},
externals: [nodeExternals()], // Para evitar empaquetar módulos de node
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
},
resolve: {
fallback: {
"stream": require.resolve("stream-browserify"),
"buffer": require.resolve("buffer/")
}
},
plugins: [
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
})
]
};
Loading
Loading