Skip to content

Instantly share code, notes, and snippets.

@alexbaumgertner
Last active February 23, 2024 11:23
Show Gist options
  • Save alexbaumgertner/6195107b2e17322d98b9c842d5290a6e to your computer and use it in GitHub Desktop.
Save alexbaumgertner/6195107b2e17322d98b9c842d5290a6e to your computer and use it in GitHub Desktop.
Docker and private github packages
ARG DEPS_IMAGE=deps-installer:latest
FROM $DEPS_IMAGE as deps-installer
FROM node:8.15.0-alpine
WORKDIR /app
COPY ./ ./
COPY --from=deps-installer /deps/node_modules ./node_modules
RUN yarn run build-production
FROM node:8.15.0-alpine as deps-installer
ARG GITHUB_TOKEN
ENV GITHUB_TOKEN=${GITHUB_TOKEN}
# For npm-packages from private github-repo (begin)
RUN apk add --no-cache git openssh
RUN git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/".insteadOf "git@github.com:"
# For npm-packages from private github-repo (end)
WORKDIR /deps
COPY ./package.json ./
COPY ./yarn.lock ./
# `--network-concurrency 1` for MacOS
RUN yarn install --non-interactive --network-concurrency 1
version: '3'
services:
# Additional containers
## Deps installing (begin)
deps-installer:
build:
context: .
dockerfile: deps-installer.Dockerfile
args:
- GITHUB_TOKEN=${GITHUB_TOKEN}
## Deps installing (end)
#!/usr/bin/env bash
# Additional containers
## Deps installing
docker-compose build deps-installer # your-prodject-name_deps-installer:latest
## Static files builders
docker-compose build app-builder # your-prodject-name__app-builder:latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment