Skip to content

Instantly share code, notes, and snippets.

@arthurgeek
Forked from enriquesaid/Dockerfile
Last active October 24, 2023 12:35
Show Gist options
  • Select an option

  • Save arthurgeek/c7f81f728d6aef1cf6750f8a692d71f7 to your computer and use it in GitHub Desktop.

Select an option

Save arthurgeek/c7f81f728d6aef1cf6750f8a692d71f7 to your computer and use it in GitHub Desktop.

Revisions

  1. arthurgeek revised this gist Oct 24, 2023. 2 changed files with 5 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,15 @@
    FROM node:20 as development
    FROM node:20-alpine as development
    WORKDIR /app
    COPY package*.json .
    RUN npm install
    COPY . .
    EXPOSE 3000
    EXPOSE 4321
    CMD [ "npm", "run", "start" ]

    FROM development as builder
    WORKDIR /app
    RUN npm run build

    FROM httpd:2.4-alpine as production
    FROM nginx:1.25.2-alpine-slim as production
    COPY --from=builder /app/dist /usr/local/apache2/htdocs/
    EXPOSE 80
    2 changes: 2 additions & 0 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -7,3 +7,5 @@ services:
    - "3000:4321"
    volumes:
    - "./:/app"
    - "/app/.tscache"
    - "/app/node_modules"
  2. arthurgeek revised this gist Oct 24, 2023. 3 changed files with 14 additions and 9 deletions.
    1 change: 1 addition & 0 deletions .dockerignore
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    node_modules
    14 changes: 10 additions & 4 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,15 @@
    FROM node:20-alpine as build
    FROM node:20 as development
    WORKDIR /app
    COPY . .
    COPY package*.json .
    RUN npm install
    COPY . .
    EXPOSE 3000
    CMD [ "npm", "run", "start" ]

    FROM development as builder
    WORKDIR /app
    RUN npm run build

    FROM httpd:2.4 as runtime
    COPY --from=build /app/dist /usr/local/apache2/htdocs/
    FROM httpd:2.4-alpine as production
    COPY --from=builder /app/dist /usr/local/apache2/htdocs/
    EXPOSE 80
    8 changes: 3 additions & 5 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,9 @@
    services:
    web:
    build: .
    command: npm start
    build:
    context: .
    target: development
    ports:
    - "3000:4321"
    volumes:
    - "./:/app"
    - "/app/.tscache"
    - "/app/dist"
    - "/app/node_modules"
  3. @enriquesaid enriquesaid revised this gist Oct 24, 2023. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    services:
    web:
    build: .
    command: npm start
    ports:
    - "3000:4321"
    volumes:
    - "./:/app"
    - "/app/.tscache"
    - "/app/dist"
    - "/app/node_modules"
  4. @enriquesaid enriquesaid created this gist Oct 24, 2023.
    9 changes: 9 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    FROM node:20-alpine as build
    WORKDIR /app
    COPY . .
    RUN npm install
    RUN npm run build

    FROM httpd:2.4 as runtime
    COPY --from=build /app/dist /usr/local/apache2/htdocs/
    EXPOSE 80