Skip to content

Instantly share code, notes, and snippets.

@r17x
Last active February 17, 2019 09:14
Show Gist options
  • Select an option

  • Save r17x/5041567f8b67a0d4ddd1a1ee65aecfcb to your computer and use it in GitHub Desktop.

Select an option

Save r17x/5041567f8b67a0d4ddd1a1ee65aecfcb to your computer and use it in GitHub Desktop.
Dockerize Nginx with Node for static files
#!/bin/bash
# create Dockerfile
# make sure this script run in your app directory
# I'm use node v8.12.0 (you can change)
cat <<EOF > Dockerfile
FROM node:8.12.0 as buildx
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn
COPY . ./
RUN yarn build
FROM nginx:1.12-alpine
COPY --from=buildx /usr/src/app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
EOF
# you can change ri7nz/medicine-docker as you want
docker build . -t ri7nz/medicine-docker
# auto run :D
docker run -p 8080:80 ri7nz/medicine-docker:latest
# if this work, go check your http://localhost:8080 in browser or
# curl http://localhost:8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment