- Add revision history
- Sync versions of nodejs in dev and prod images
- Fix incorrect nodejs version in dev image
- Add mode ingores from template .gitignore, remove unnecessary "npm cache clean"
- Add Makefile with current user, list of images, .env
- Fix revision history
Last active
April 21, 2020 03:33
-
-
Save alldevic/ff8d7c6d654c1ca05784435ee539c427 to your computer and use it in GitHub Desktop.
Svelte+sapper dockerize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__sapper__ | |
.dockerignore | |
.gitignore | |
cypress/screenshots/ | |
docker-compose.yml | |
Dockerfile | |
**/node_modules | |
npm-debug.log | |
package-lock.json | |
yarn-error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEBUG=False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.4" | |
services: | |
frontend-dev: | |
container_name: frontend-dev | |
user: ${CURRENT_UID} | |
image: node:12.15.0-alpine3.11 | |
working_dir: /app/ | |
volumes: | |
- .:/app | |
ports: | |
- 3000:3000 | |
- 10000:10000 | |
command: > | |
sh -c " \ | |
rm -rf ./node_modules/ ./src/node_modules/ package-lock.json && \ | |
npm i && \ | |
npm run dev \ | |
" | |
networks: | |
default: | |
frontend-prod: | |
container_name: frontend-prod | |
user: ${CURRENT_UID} | |
build: . | |
ports: | |
- 80:3000 | |
networks: | |
default: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:3.11.5 as build-stage | |
ENV NODE_ENV=production | |
WORKDIR /temp-app/ | |
RUN apk add --no-cache nodejs=12.15.0-r1 && \ | |
apk add --no-cache --virtual .build-deps npm=12.15.0-r1 && \ | |
mkdir -p /app/ | |
COPY package.json . | |
RUN npm i && \ | |
cp -r ./node_modules /app/node_modules && \ | |
npm i --only=dev | |
COPY . . | |
RUN npm run build && \ | |
cp -r /temp-app/__sapper__/ /app/__sapper__/ && \ | |
cp -r /temp-app/static/ /app/static/ && \ | |
apk --purge del .build-deps && \ | |
rm -rf /root/.cache /root/.local /root/.npm /root/.config /tmp/* \ | |
/etc/apk/ /usr/share/apk/ /lib/apk/ /sbin/apk /media /usr/lib/terminfo \ | |
/usr/share/terminfo /var/cache/apk /var/lib/apk /temp-app | |
FROM scratch as deploy-stage | |
ENV NODE_ENV=production | |
COPY --from=build-stage / / | |
WORKDIR /app/ | |
EXPOSE 3000 | |
ENTRYPOINT [ "node", "__sapper__/build" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/make | |
include .env | |
export | |
SHELL = /bin/sh | |
CURRENT_UID := $(shell id -u):$(shell id -g) | |
export CURRENT_UID | |
ifeq ($(DEBUG), True) | |
IMAGES := frontend-dev | |
else | |
IMAGES := frontend-prod | |
endif | |
export IMAGES | |
up: | |
docker-compose up -d $(IMAGES) | |
upb: | |
docker-compose up -d --force-recreate --build $(IMAGES) | |
down: | |
docker-compose down | |
logs: | |
docker-compose logs -f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment