docker build & push to docker-hub


1. docker 이미지 추출

  • node.js
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    FROM node:9.4-alpine
    MAINTAINER authorize <xxx@gmail.com>
    #작업 디렉토리
    WORKDIR /src
    #원본 소스복사
    COPY ./freebex-integrated .
    # npm 설치
    RUN npm install
    #환경변수 NODE_ENV 의 값을 development 로 설정
    #ENV NODE_ENV development

    #오픈할 포트 multi: EXPOSE 80 3000
    EXPOSE 3501
    #CMD["npm","start"]
    CMD node ./bin/www

  • html on nginx
    1
    2
    3
    4
    5
    6
    #alpine image
    FROM nginx:alpine
    #create the server and location configuration
    COPY default.conf /etc/nginx/conf.d/default.conf
    #copies the build app to the default location
    COPY client/dist/mobile /usr/share/nginx/html

2. 이미지 빌드

1
docker build --rm -f Dockerfile -t [image-name]:latest .

3. 이미지 푸시(docker hub)

1
2
docker tag [image-name]:latest [docker-hub ID]/[image-name]:latest
docker push [docker-hub ID]/[image-name]:latest
공유