From f353f21d0f3fa6ae4bada0efd7275adee7c130a1 Mon Sep 17 00:00:00 2001
From: L4168 <L4168@student.jamk.fi>
Date: Tue, 25 Jun 2019 08:15:37 +0300
Subject: [PATCH] gitlab-ci test

---
 .gitignore                     |  1 +
 gitlab-ci.yml                  | 18 ++++++++++++++++++
 src/components/Header.js       |  2 +-
 src/components/LoginForm.js    |  2 +-
 src/components/RegisterForm.js |  2 +-
 5 files changed, 22 insertions(+), 3 deletions(-)
 create mode 100644 gitlab-ci.yml

diff --git a/.gitignore b/.gitignore
index 4d29575..f21726c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,6 +17,7 @@
 .env.development.local
 .env.test.local
 .env.production.local
+.env
 
 npm-debug.log*
 yarn-debug.log*
diff --git a/gitlab-ci.yml b/gitlab-ci.yml
new file mode 100644
index 0000000..ccabf64
--- /dev/null
+++ b/gitlab-ci.yml
@@ -0,0 +1,18 @@
+stages:
+  - push-image
+
+docker-push:
+  image: docker
+  services:
+    - docker:dind
+  stage: push-image
+  tags: ['docker']
+  only:
+    - testing
+  before_script:
+    - echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USER" --password-stdin
+  script:
+    - docker build --build-arg REACT_APP_URL=${REACT_APP_URL} -t overflow2019/frontend:test .
+    - docker push overflow2019/frontend
+  after_script:
+    - docker logout
diff --git a/src/components/Header.js b/src/components/Header.js
index 7079906..69ca464 100644
--- a/src/components/Header.js
+++ b/src/components/Header.js
@@ -35,7 +35,7 @@ class Header extends React.Component {
   componentDidMount() {
     let token = sessionStorage.getItem('token');
     if (token) {
-      fetch('http://localhost:5000/user/verify', {
+      fetch(`${process.env.REACT_APP_URL}/user/verify`, {
         headers: {
           Authorization: 'Bearer ' + token
         }
diff --git a/src/components/LoginForm.js b/src/components/LoginForm.js
index 7893bb8..fe34df7 100644
--- a/src/components/LoginForm.js
+++ b/src/components/LoginForm.js
@@ -38,7 +38,7 @@ export class LoginForm extends React.Component {
     e.preventDefault();
 
     // Send login info to the server
-    fetch('http://localhost:5000/user/login', {
+    fetch(`${process.env.REACT_APP_URL}/user/login`, {
       method: 'POST',
       headers: {
         Accept: 'application/json',
diff --git a/src/components/RegisterForm.js b/src/components/RegisterForm.js
index f0ead02..b50187d 100644
--- a/src/components/RegisterForm.js
+++ b/src/components/RegisterForm.js
@@ -44,7 +44,7 @@ export class RegisterForm extends React.Component {
       this.handleError('Passwords do not match');
     } else {
       // Send register info to the server
-      fetch('http://localhost:5000/user/register', {
+      fetch(`${process.env.REACT_APP_URL}/user/register`, {
         method: 'POST',
         headers: {
           Accept: 'application/json',
-- 
GitLab