You will need roughly 3 minutes to read this article.
We’ve got quickstart repos, sample apps and a getting started guide available to make starting out with CodeShip Pro faster and easier.
Any Node tool that can run inside a Docker container will run on CodeShip Pro. This documentation article will highlight simple configuration files for a Node-based Dockerfile with tests.
We have a sample Node repo that you can clone or take a look at via the GitHub codeship-library/nodejs-express-todoapp repository. This may make a good starting point for your Node-based projects.
When accessing other containers please be aware that those services do not run on
localhost, but on a different host, e.g.
mysql. If you reference
localhost in any of your configuration files you will have to change that to point to the service name of the service you want to access. Setting them through environment variables and using those inside of your configuration files is the cleanest approach to setting up your build environment.
project_name: build: image: organisation_name/project_name dockerfile: Dockerfile depends_on: - redis - postgres environment: - DATABASE_URL=postgres://postgres@postgres/YOUR_DATABASE_NAME - REDIS_URL=redis://redis redis: image: healthcheck/redis:alpine postgres: image: healthcheck/postgres:alpine
Note that in this example we are using the healthcheck version of our Redis and PostgreSQL images to avoid startup timing issues.
The following is an example of a CodeShip Steps file.
Note that every step runs in isolated containers, so changes made on one step do not persist to the next step. Because of this, any required setup commands, such as migrating a database, should be done via a custom Dockerfile, via a
entrypoint on a service or repeated on every step.
- name: ci type: parallel steps: - service: project_name command: npm run-script test-acceptance - service: project_name command: npm run-script test-unit
Following is an example Dockerfile with inline comments describing each step in the file. The Dockerfile shows the different ways you can install extensions or dependencies so you can extend it to fit exactly what you need. Also take a look at the Node image documentation on the Docker Hub.
# We're starting from the Node 8 image FROM node:8 # INSTALL any further tools you need here so they are cached in the docker build # Set the WORKDIR to /app so all following commands run in /app WORKDIR /app # COPY the package.json and if you use npm shrinkwrap the npm-shrinkwrap.json and # install npm dependencies before copying the whole codebase into the image. COPY package.json ./ && npm-shrinkwrap.json ./ RUN npm install # After installing dependencies copy the whole codebase into the Container to not invalidate the cache before COPY . ./
Because of version and test dependency issues, it is advised to try using the Jet CLI to debug issues locally via
You can install webpack via NPM in your services’ Dockerfile, as seen below:
RUN npm install webpack
Note that you may need to specify a specific version of Node in the Dockerfile to use webpack successfully.
You can enable caching per service in your Services file.
Contact our support team or post on Stack Overflow using the tag
#codeship. Did you check the status page and changelog?
There are also several code examples and sample projects available for you to get started with.