Skip to content

Commit

Permalink
Merge pull request #279 from computas/docker_frontend
Browse files Browse the repository at this point in the history
Set up docker
  • Loading branch information
Ivan-Computas authored Oct 11, 2024
2 parents ecf5c39 + 370c76b commit 9cca2a7
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
node_modules
Dockerfile*
docker-compose*
.dockerignore
.git
.gitignore
README.md
LICENSE
.vscode
Makefile
helm-charts
.env
.editorconfig
.idea
coverage*
60 changes: 60 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
FROM node:18 AS base
WORKDIR /app

# Copy package.json and bun.lockb
COPY package.json .
COPY bun.lockb .

# Install Bun
RUN curl -fsSL https://bun.sh/install | bash

# Add Bun to PATH
ENV BUN_INSTALL="/root/.bun"
ENV PATH="$BUN_INSTALL/bin:$PATH"

# Install dependencies using Bun
RUN bun install --frozen-lockfile
RUN npm install -g @angular/cli
RUN bun install

# --- DEVELOPMENT STAGE ---

FROM base AS development
ENV NODE_ENV=development

COPY . /app

EXPOSE 4200

# Run the app in development mode using ng serve
CMD ["bun", "run", "start"]

# --- BUILD STAGE ---
FROM base AS build

# Copy all files for the build
COPY . /app

RUN ng build --configuration ComputasProd

RUN apt update && apt install -y nginx && \
rm -rf /var/lib/apt/lists/*

# --- PRODUCTION STAGE ---
FROM nginx:alpine AS production
ENV NODE_ENV=production

# Copy the source code for building the production build
COPY . /app

# Copy built files from the build stage to the Nginx html directory
COPY --from=build /app/dist/tekniskmuseum /usr/share/nginx/html

# Copy the custom Nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Expose the Nginx port
EXPOSE 80

# Start Nginx
CMD ["nginx", "-g", "daemon off;"]
16 changes: 16 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
server {
listen 80;

server_name localhost;

root /usr/share/nginx/html;

location / {
try_files $uri $uri/ /index.html;
}

location /assets/ {

try_files $uri $uri/ /index.html;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"version": "0.0.0",
"scripts": {
"prettier": "prettier --end-of-line=crlf --write src/**/*.ts",
"start": "ng serve",
"start": "ng serve --host 0.0.0.0",
"build": "ng build",
"build:ci": "ng build --configuration production",
"build:computas": "ng build --configuration computas",
Expand Down

0 comments on commit 9cca2a7

Please sign in to comment.